Submission #862013

# Submission time Handle Problem Language Result Execution time Memory
862013 2023-10-17T11:24:55 Z 8pete8 Snowball (JOI21_ho_t2) C++14
100 / 100
90 ms 10552 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<bitset> 
#include<stack>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define pppiiii pair<pii,pii>
#define ppii pair<int,pii>
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
const int mxn=5e5+10,mx=5e6+10,minf=-1e9;
int32_t main(){
    fastio
    int n,q;cin>>n>>q;
    vector<int>pos(n),ans(n,0);
    for(int i=0;i<n;i++)cin>>pos[i];
    vector<int>mn(q+1,0),mx(q+1,0);
    int cur=0;
    for(int i=1;i<=q;i++){
        int k;cin>>k;
        cur+=k;
        if(i)mn[i]=mn[i-1],mx[i]=mx[i-1];
        mn[i]=min(mn[i],cur);
        mx[i]=max(mx[i],cur);
    }
    ans[0]-=mn[q];
    ans[n-1]+=mx[q];
    for(int i=0;i<n-1;i++){
        int l=0,r=q,a=0;
        while(l<=r){
            int mid=l+(r-l)/2;
            if(pos[i+1]+mn[mid]>pos[i]+mx[mid]){
                a=max(a,mid);
                l=mid+1;
            }
            else r=mid-1;
        }
        ans[i]+=mx[a];
        ans[i+1]-=mn[a];
        if(a<q){
            int diff=(pos[i+1]+mn[a])-(pos[i]+mx[a]);
            if(mx[a+1]>mx[a])ans[i]+=diff;
            else ans[i+1]+=diff;
        }
    }
    for(auto i:ans)cout<<i<<'\n';
}
/*
4 5 3 100
2 80 100
5 125 130
4 75 150
3 120 110
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 30 ms 4868 KB Output is correct
21 Correct 19 ms 4876 KB Output is correct
22 Correct 18 ms 4444 KB Output is correct
23 Correct 18 ms 4656 KB Output is correct
24 Correct 22 ms 5096 KB Output is correct
25 Correct 80 ms 10236 KB Output is correct
26 Correct 77 ms 10300 KB Output is correct
27 Correct 88 ms 10036 KB Output is correct
28 Correct 78 ms 10052 KB Output is correct
29 Correct 90 ms 9784 KB Output is correct
30 Correct 72 ms 9228 KB Output is correct
31 Correct 50 ms 8784 KB Output is correct
32 Correct 56 ms 8716 KB Output is correct
33 Correct 8 ms 1668 KB Output is correct
34 Correct 85 ms 10552 KB Output is correct
35 Correct 74 ms 10108 KB Output is correct
36 Correct 87 ms 10300 KB Output is correct
37 Correct 76 ms 10068 KB Output is correct
38 Correct 76 ms 9948 KB Output is correct
39 Correct 73 ms 8020 KB Output is correct
40 Correct 51 ms 8020 KB Output is correct
41 Correct 21 ms 3420 KB Output is correct
42 Correct 44 ms 6996 KB Output is correct
43 Correct 74 ms 8272 KB Output is correct
44 Correct 20 ms 3416 KB Output is correct
45 Correct 49 ms 8020 KB Output is correct
46 Correct 54 ms 8276 KB Output is correct
47 Correct 59 ms 8400 KB Output is correct
48 Correct 72 ms 8272 KB Output is correct