Submission #756354

# Submission time Handle Problem Language Result Execution time Memory
756354 2023-06-11T15:23:45 Z 1075508020060209tc Snowball (JOI21_ho_t2) C++14
100 / 100
557 ms 18468 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;int Q;
int xar[200005];
int adar[200005];
int psad[200005];
int mnad[200005];
int mxad[200005];

int lans[200005];
int rans[200005];


signed main(){
cin>>n>>Q;
for(int i=1;i<=n;i++){
    cin>>xar[i];
}
for(int i=1;i<=Q;i++){
    cin>>adar[i];
    psad[i]=adar[i]+psad[i-1];
    mnad[i]=min(mnad[i-1],psad[i]);
    mxad[i]=max(mxad[i-1],psad[i]);
}
lans[1]=xar[1]+mnad[Q];
rans[n]=xar[n]+mxad[Q];

for(int i=1;i<=n-1;i++){
    int l=0;int r=Q;
    while(l<r){
        int mi=l+(r-l+1)/2;
        if( xar[i]+mxad[mi]<=xar[i+1]+mnad[mi] ){
            l=mi;
        }else{
            r=mi-1;
        }
    }
    if(   ((l==Q)||(l!=Q&&adar[l+1]<0))   ){
        rans[i]=xar[i]+mxad[l];
    }else{
        rans[i]=xar[i+1]+mnad[l];
    }
}


for(int i=n;i>=2;i--){
    int l=0;int r=Q;
    while(l<r){
        int mi=l+(r-l+1)/2;
        if( xar[i]+mnad[mi]>=xar[i-1]+mxad[mi] ){
            l=mi;
        }else{
            r=mi-1;
        }
    }
    if( (l==Q||adar[l+1]>0) ){
        lans[i]=xar[i]+mnad[l];
    }else{
        lans[i]=xar[i-1]+mxad[l];
    }

}
for(int i=1;i<=n;i++){
    cout<<rans[i]-lans[i]<<endl;
}






}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 352 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 5 ms 468 KB Output is correct
5 Correct 5 ms 468 KB Output is correct
6 Correct 5 ms 468 KB Output is correct
7 Correct 5 ms 468 KB Output is correct
8 Correct 5 ms 468 KB Output is correct
9 Correct 6 ms 468 KB Output is correct
10 Correct 5 ms 468 KB Output is correct
11 Correct 5 ms 488 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 6 ms 468 KB Output is correct
16 Correct 6 ms 468 KB Output is correct
17 Correct 5 ms 468 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 4 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 352 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 5 ms 468 KB Output is correct
5 Correct 5 ms 468 KB Output is correct
6 Correct 5 ms 468 KB Output is correct
7 Correct 5 ms 468 KB Output is correct
8 Correct 5 ms 468 KB Output is correct
9 Correct 6 ms 468 KB Output is correct
10 Correct 5 ms 468 KB Output is correct
11 Correct 5 ms 488 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 6 ms 468 KB Output is correct
16 Correct 6 ms 468 KB Output is correct
17 Correct 5 ms 468 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 4 ms 468 KB Output is correct
20 Correct 84 ms 8700 KB Output is correct
21 Correct 89 ms 8508 KB Output is correct
22 Correct 79 ms 8296 KB Output is correct
23 Correct 77 ms 8176 KB Output is correct
24 Correct 106 ms 8744 KB Output is correct
25 Correct 511 ms 16620 KB Output is correct
26 Correct 468 ms 16484 KB Output is correct
27 Correct 487 ms 16104 KB Output is correct
28 Correct 522 ms 16336 KB Output is correct
29 Correct 473 ms 15780 KB Output is correct
30 Correct 477 ms 15212 KB Output is correct
31 Correct 391 ms 14628 KB Output is correct
32 Correct 380 ms 14708 KB Output is correct
33 Correct 48 ms 1992 KB Output is correct
34 Correct 489 ms 16916 KB Output is correct
35 Correct 501 ms 16400 KB Output is correct
36 Correct 494 ms 16708 KB Output is correct
37 Correct 479 ms 16276 KB Output is correct
38 Correct 460 ms 16072 KB Output is correct
39 Correct 475 ms 16324 KB Output is correct
40 Correct 430 ms 16236 KB Output is correct
41 Correct 100 ms 9292 KB Output is correct
42 Correct 378 ms 14780 KB Output is correct
43 Correct 465 ms 18004 KB Output is correct
44 Correct 106 ms 9164 KB Output is correct
45 Correct 432 ms 16316 KB Output is correct
46 Correct 557 ms 18220 KB Output is correct
47 Correct 498 ms 18388 KB Output is correct
48 Correct 491 ms 18468 KB Output is correct