Submission #689730

# Submission time Handle Problem Language Result Execution time Memory
689730 2023-01-29T08:34:49 Z prairie2022 Snowball (JOI21_ho_t2) C++17
100 / 100
113 ms 15548 KB
#include <bits/stdc++.h>
#define int long long
#define fastio cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define p pair<int, int>
#define f first
#define s second
using namespace std;


signed main(){
    fastio
    int n, q, l=0, r=0, cur=0, w;
    cin >> n >> q;
    vector<pair<int, p>> x(n);
    vector<p> y;
    auto it=y.begin();
    for(int i=0; i<n; i++){
        cin >> x[i].f;
    }
    for(int i=0; i<q; i++){
        cin >> w;
        cur += w;
        if(w>0 && cur>r){
            r = cur;
            y.push_back(make_pair(r-l, l-1));
        }
        if(w<0 && cur<l){
            l = cur;
            y.push_back(make_pair(r-l, r+1));
        }
    }
    /*for(const auto &c: y){
        cout << c.f << ' ' << c.s << '\n';
    }*/
    x[0].s.f = l;
    x[n-1].s.s = r;
    for(int i=1; i<n; i++){
        it = lower_bound(y.begin(), y.end(), make_pair(x[i].f-x[i-1].f, 0ll));
        if(it==y.end()){
            x[i-1].s.s = r;
            x[i].s.f = l;
        }
        else if(it->s>0){
            x[i-1].s.s = it->s-1;
            x[i].s.f = x[i-1].s.s-x[i].f+x[i-1].f;
        }
        else{
            x[i].s.f = it->s+1;
            x[i-1].s.s = x[i].f-x[i-1].f+x[i].s.f;
        }
    }
    for(int i=0; i<n; i++){
        cout << x[i].s.s-x[i].s.f << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 380 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 408 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 404 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 380 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 408 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 404 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 27 ms 6148 KB Output is correct
21 Correct 25 ms 6032 KB Output is correct
22 Correct 27 ms 5900 KB Output is correct
23 Correct 23 ms 5812 KB Output is correct
24 Correct 31 ms 6452 KB Output is correct
25 Correct 94 ms 13504 KB Output is correct
26 Correct 113 ms 13428 KB Output is correct
27 Correct 87 ms 12916 KB Output is correct
28 Correct 88 ms 12824 KB Output is correct
29 Correct 84 ms 11004 KB Output is correct
30 Correct 71 ms 8972 KB Output is correct
31 Correct 54 ms 8328 KB Output is correct
32 Correct 49 ms 8468 KB Output is correct
33 Correct 8 ms 1688 KB Output is correct
34 Correct 74 ms 10884 KB Output is correct
35 Correct 81 ms 10500 KB Output is correct
36 Correct 98 ms 13316 KB Output is correct
37 Correct 92 ms 12932 KB Output is correct
38 Correct 85 ms 12800 KB Output is correct
39 Correct 86 ms 13056 KB Output is correct
40 Correct 68 ms 13064 KB Output is correct
41 Correct 37 ms 6596 KB Output is correct
42 Correct 47 ms 8444 KB Output is correct
43 Correct 75 ms 15100 KB Output is correct
44 Correct 31 ms 6436 KB Output is correct
45 Correct 61 ms 13056 KB Output is correct
46 Correct 96 ms 15228 KB Output is correct
47 Correct 77 ms 13380 KB Output is correct
48 Correct 75 ms 15548 KB Output is correct