Submission #534819

# Submission time Handle Problem Language Result Execution time Memory
534819 2022-03-09T03:08:22 Z Paul_Liao_1457 Snowball (JOI21_ho_t2) C++14
0 / 100
22 ms 388 KB
// 還要更強
#include<iostream>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<math.h>
#include<cstring>
#include<stack>
#include<string.h>
#include<random>
#include<algorithm>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define INF (ll)(4e18)
#define pb push_back
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int n,q;
vector<ll> v,Q;
ll ans[200005];

signed main(){
    AC;
    cin>>n>>q;
    v.pb(-INF);
    FOR(i,0,n){
        ll x; cin>>x;
        v.pb(x);
    }
    v.pb(INF);
    FOR(i,0,q){
        ll y; cin>>y;
        Q.pb(y);
    }
    FOR(i,1,n+1){
        ll now=0,maxn=-INF,minn=v[i];
        //cout<<"i="<<i<<endl;
        FOR(j,0,q){
            now+=Q[j]; maxn=max(maxn,now);
            if(now<0){
                minn=min(minn,max(v[i-1]+maxn,v[i]+now));
            }
        }
        //cout<<"minn="<<minn<<endl;
        ans[i]+=v[i]-minn;
        maxn=v[i]; now=0; minn=INF;
        FOR(j,0,q){
            now+=Q[j]; minn=min(minn,now);
            //cout<<"now="<<now<<" minn="<<minn<<endl;
            if(now>0){
                maxn=max(maxn,min(v[i+1]+minn,v[i]+now));
            }
        }
        //cout<<"maxn="<<maxn<<endl;
        ans[i]+=maxn-v[i];
    }
    FOR(i,1,n+1) cout<<ans[i]<<endl;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 21 ms 332 KB Output is correct
5 Correct 21 ms 388 KB Output is correct
6 Correct 22 ms 372 KB Output is correct
7 Incorrect 21 ms 380 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 21 ms 332 KB Output is correct
5 Correct 21 ms 388 KB Output is correct
6 Correct 22 ms 372 KB Output is correct
7 Incorrect 21 ms 380 KB Output isn't correct
8 Halted 0 ms 0 KB -