zoukankan      html  css  js  c++  java
  • 【codeforces 767A】Snacktower

    【题目链接】:http://codeforces.com/contest/767/problem/A

    【题意】

    每天掉一个盘子下来;盘子有大小从1..n依次增大n个盘子;
    然后让你叠盘子;
    最底层为n,倒数第二层为n-1….最上层为1;
    让你输出每天叠了哪些盘子;

    【题解】

    因为是要连续叠在一起的;
    所以每一天其实都有一个固定要等待的盘子;
    如果等到了那个盘子;
    就一直往下走;输出连续的盘子;
    没有的话,它就是下一个需要等待的盘子了;

    【完整代码】

    #include <bits/stdc++.h>
    using namespace std;
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    #define rep1(i,a,b) for (int i = a;i <= b;i++)
    #define rep2(i,a,b) for (int i = a;i >= b;i--)
    #define mp make_pair
    #define ps push_back
    #define fi first
    #define se second
    #define rei(x) scanf("%d",&x)
    #define rel(x) scanf("%lld",&x)
    #define ref(x) scanf("%lf",&x)
    
    typedef pair<int, int> pii;
    typedef pair<LL, LL> pll;
    
    const int dx[9] = { 0,1,-1,0,0,-1,-1,1,1 };
    const int dy[9] = { 0,0,0,-1,1,-1,1,-1,1 };
    const double pi = acos(-1.0);
    const int N = 1e5+100;
    
    int n;
    int wait;
    int chuxian[N];
    
    int main()
    {
        //freopen("D:\rush.txt", "r", stdin);
        rei(n);
        wait = n;
        rep1(i,1,n)
        {
            int x;
            rei(x);
            chuxian[x] = 1;
            while (chuxian[wait])
            {
                printf("%d ",wait);
                wait--;
            }
            puts("");
        }
        //printf("
    %.2lf sec 
    ", (double)clock() / CLOCKS_PER_SEC);
        return 0;
    }
  • 相关阅读:
    (Eclipse) Selection does not contain main type
    Spring Web Flow 学习笔记(2)-流程的组件
    Spring Web Flow 学习笔记(1)
    快速排序java实现
    二路归并排序
    剪切板
    Java中空白final
    对象引用和对象
    Java复用类
    Experimenrs on Foursquare
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626503.html
Copyright © 2011-2022 走看看