답안 #534215

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534215 2022-03-08T02:25:37 Z Biaz Snowball (JOI21_ho_t2) C++17
33 / 100
2500 ms 4016 KB
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define X first
#define Y second
#define ist insert
typedef long long ll;
//typedef pair<int,int> pii;
using namespace std;
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
const int INF=1700000000000000;//2147483647;
const int MOD=998244353;//1000000007;
const int N=200005;
int n,Q;
int a[N],w[N],res[N];
int mxL[N],mxR[N];
void sol(){
    cin >>n>>Q;
    for (int i=1;i<=n;i++)
        cin >>a[i],mxL[i]=mxR[i]=a[i];
    a[0]=mxL[0]=mxR[0]=-INF;mxL[n+1]=mxR[n+1]=a[n+1]=INF;
    for (int i=1;i<=Q;i++)
        cin >>w[i];

    int cur=0;
    for (int xx=1;xx<=Q;xx++){
        cur+=w[xx];
        for (int i=1;i<=n;i++){
            if (mxL[i]<=a[i]+cur&&a[i]+cur<=mxR[i]) continue;
            if (cur>0) res[i]+=max(0,min(mxL[i+1],a[i]+cur)-mxR[i]);
            if (cur<0) res[i]+=max(0,mxL[i]-max((a[i]+cur),mxR[i-1]));
        }
        for (int i=1;i<=n;i++){
            mxL[i]=min(mxL[i],a[i]+cur);
            mxR[i]=max(mxR[i],a[i]+cur);
        }
        /*for (int i=1;i<=n;i++)
        cout <<res[i]<<' ';cout <<'\n';
        for (int i=1;i<=n;i++)
            cout <<mxL[i]<<' '<<mxR[i]<<'\n';*/
    }
    
    for (int i=1;i<=n;i++)
        cout <<res[i]<<'\n';
}
signed main()
{
    int _=1;
    //cin >>_;
    while (_--) sol();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 2 ms 312 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 15 ms 436 KB Output is correct
5 Correct 15 ms 460 KB Output is correct
6 Correct 14 ms 436 KB Output is correct
7 Correct 14 ms 460 KB Output is correct
8 Correct 14 ms 332 KB Output is correct
9 Correct 12 ms 444 KB Output is correct
10 Correct 12 ms 432 KB Output is correct
11 Correct 10 ms 408 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 15 ms 440 KB Output is correct
16 Correct 14 ms 460 KB Output is correct
17 Correct 15 ms 460 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 11 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 2 ms 312 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 15 ms 436 KB Output is correct
5 Correct 15 ms 460 KB Output is correct
6 Correct 14 ms 436 KB Output is correct
7 Correct 14 ms 460 KB Output is correct
8 Correct 14 ms 332 KB Output is correct
9 Correct 12 ms 444 KB Output is correct
10 Correct 12 ms 432 KB Output is correct
11 Correct 10 ms 408 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 15 ms 440 KB Output is correct
16 Correct 14 ms 460 KB Output is correct
17 Correct 15 ms 460 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 11 ms 312 KB Output is correct
20 Correct 92 ms 3916 KB Output is correct
21 Correct 89 ms 3712 KB Output is correct
22 Correct 185 ms 3516 KB Output is correct
23 Correct 1262 ms 3500 KB Output is correct
24 Execution timed out 2575 ms 4016 KB Time limit exceeded
25 Halted 0 ms 0 KB -