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;
    }
  • 相关阅读:
    java期末复习2
    java期末复习
    Educational Codeforces Round 76 (Rated for Div. 2)
    ICPC南昌时间安排
    codeforces 597 div2 ABCDF
    codeforces 597 div2 ABC
    Vue中provide和inject 用法
    Js打印九九乘法表
    document.documentElement和document.body的区别
    移动端关于横屏问题
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626503.html
Copyright © 2011-2022 走看看