답안 #534820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534820 2022-03-09T03:09:30 Z Paul_Liao_1457 Snowball (JOI21_ho_t2) C++14
33 / 100
2500 ms 2688 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)(3e18)
#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=0,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=0;
        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;
}

# 결과 실행 시간 메모리 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 23 ms 372 KB Output is correct
5 Correct 25 ms 376 KB Output is correct
6 Correct 26 ms 380 KB Output is correct
7 Correct 22 ms 380 KB Output is correct
8 Correct 24 ms 332 KB Output is correct
9 Correct 25 ms 376 KB Output is correct
10 Correct 22 ms 372 KB Output is correct
11 Correct 14 ms 388 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 24 ms 376 KB Output is correct
16 Correct 23 ms 372 KB Output is correct
17 Correct 23 ms 372 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 11 ms 380 KB Output is correct
# 결과 실행 시간 메모리 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 23 ms 372 KB Output is correct
5 Correct 25 ms 376 KB Output is correct
6 Correct 26 ms 380 KB Output is correct
7 Correct 22 ms 380 KB Output is correct
8 Correct 24 ms 332 KB Output is correct
9 Correct 25 ms 376 KB Output is correct
10 Correct 22 ms 372 KB Output is correct
11 Correct 14 ms 388 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 24 ms 376 KB Output is correct
16 Correct 23 ms 372 KB Output is correct
17 Correct 23 ms 372 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 11 ms 380 KB Output is correct
20 Correct 34 ms 2688 KB Output is correct
21 Correct 75 ms 2504 KB Output is correct
22 Correct 459 ms 2444 KB Output is correct
23 Execution timed out 2524 ms 2516 KB Time limit exceeded
24 Halted 0 ms 0 KB -