zoukankan      html  css  js  c++  java
  • [HDOJ5500]Reorder the Books

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5500

    模拟,从最大的开始找,一旦找到最大的,前面有对应顺序次大的话,那么那个次大的就不需要移动。以此类推,注意要保证他们的相对顺序。

     1 #include <algorithm>
     2 #include <iostream>
     3 #include <iomanip>
     4 #include <cstring>
     5 #include <climits>
     6 #include <complex>
     7 #include <fstream>
     8 #include <cassert>
     9 #include <cstdio>
    10 #include <bitset>
    11 #include <vector>
    12 #include <deque>
    13 #include <queue>
    14 #include <stack>
    15 #include <ctime>
    16 #include <set>
    17 #include <map>
    18 #include <cmath>
    19 
    20 using namespace std;
    21 
    22 const int maxn = 20;
    23 int n;
    24 int book[maxn];
    25 
    26 int main() {
    27     int T_T;
    28     scanf("%d", &T_T);
    29     while(T_T--) {
    30         scanf("%d", &n);
    31         for(int i = 1; i <= n; i++) {
    32             scanf("%d", &book[i]);
    33         }
    34         int cnt = n;
    35         for(int i = n; i > 0; i--) {
    36             if(cnt == book[i]) {
    37                 cnt--;
    38             }
    39         }
    40         printf("%d
    ", cnt);
    41     }
    42 }
    View Code
  • 相关阅读:
    TCP/IP四层模型
    Java中equals和==的区别
    最全前端资源汇集
    (转)php面向对象学习笔记
    学习内容
    Gulp入门教程
    seajs的CMD模式的优势以及使用
    正则
    Grunt
    Javascript 异步加载详解
  • 原文地址:https://www.cnblogs.com/kirai/p/4869317.html
Copyright © 2011-2022 走看看