zoukankan      html  css  js  c++  java
  • Codeforces1486 A Shifting Stacks (开long long)

    原题链接
    思路:
    一觉醒来红了个题,一看发现没开ll,我大意了啊。
    构造出0,1,2……的序列就行,如果少的话看前面多的能不能补上。
    代码:

    #pragma GCC optimize(2)
    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;typedef unsigned long long ull;
    typedef pair<ll,ll>PLL;typedef pair<int,int>PII;typedef pair<double,double>PDD;
    #define I_int ll
    inline ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
    #define read read()
    #define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
    #define multiCase int T;cin>>T;for(int t=1;t<=T;t++)
    #define rep(i,a,b) for(int i=(a);i<=(b);i++)
    #define repp(i,a,b) for(int i=(a);i<(b);i++)
    #define per(i,a,b) for(int i=(a);i>=(b);i--)
    #define perr(i,a,b) for(int i=(a);i>(b);i--)
    ll ksm(ll a,ll b,ll p){ll res=1;while(b){if(b&1)res=res*a%p;a=a*a%p;b>>=1;}return res;}
    const int maxn=1e6+7;
    ll a[maxn],n;
    void solve(){
        n=read;
        rep(i,1,n) a[i]=read;
        ll las=-1,sum=0;
        rep(i,1,n){
            las++;
            if(a[i]>=las){
                sum+=a[i]-las;
            }
            else{
                int t=las-a[i];
                if(sum>=t) sum-=t;
                else{
                    puts("NO");
                    return ;
                }
            }
        }
        puts("YES");
    }
    
    int main(){
    	int T=read;
    	while(T--) solve();
    	return 0;
    }
    
    
  • 相关阅读:
    链表
    Wonder团队承接各种Web3D业务
    真我的信息
    一个人独自做长期项目,如何提高工作效率?
    【Java】类的结构
    【长知识】找书攻略
    【长知识】语义化版本控制
    【Java】Debug调试常用技巧
    【Web】Servlet三大作用域、JSP四大作用域
    【Web】Servlet基本概念
  • 原文地址:https://www.cnblogs.com/OvOq/p/14853045.html
Copyright © 2011-2022 走看看