Submission #638115

# Submission time Handle Problem Language Result Execution time Memory
638115 2022-09-04T16:03:24 Z Astrayt Snowball (JOI21_ho_t2) C++17
100 / 100
88 ms 13740 KB
//君の手を握ってしまったら
//孤独を知らないこの街には
//もう二度と帰ってくることはできないのでしょう
//君が手を差し伸べた 光で影が生まれる
//歌って聞かせて この話の続き
//連れて行って見たことない星まで
//さユリ - 花の塔
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second

void solve(){
    int N, Q; cin >> N >> Q;
    vector<int> v(N), ans(N, 0);
    vector<pii> snow(N - 1);
    for(auto &x:v) cin >> x;
    for(int i = 1; i < N; ++i){
        int l = v[i] - v[i - 1];
        snow[i - 1] = pii(l, i);
    }
    sort(snow.begin(), snow.end());
    int l = 0, r = 0, cur = 0, i = 0;
    for(int j = 0; j < Q; ++j){
        int w; cin >> w;
        cur += w;
        if(w > 0){
            r = max(r, cur);
            while(i < N - 1 && snow[i].ff <= l + r){
                ans[snow[i].ss] += l;
                ans[snow[i].ss - 1] += snow[i].ff - l;
                ++i;
            }
        }else{
            l = max(l, -cur);
            while(i < N - 1 && snow[i].ff <= l + r){
                ans[snow[i].ss - 1] += r;
                ans[snow[i].ss] += snow[i].ff - r;
                ++i;
            }
        }
    }
    while(i < N - 1){
        ans[snow[i].ss - 1] += r;
        ans[snow[i].ss] += l;
        ++i;
    }
    ans[0] += l;
    ans[N - 1] += r;
    for(int x:ans) cout << x << '\n';
}

signed main(){
    starburst
    int t = 1; //cin >> t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 428 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 416 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 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 340 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 2 ms 328 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 428 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 416 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 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 340 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 2 ms 328 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 29 ms 1852 KB Output is correct
21 Correct 24 ms 1796 KB Output is correct
22 Correct 24 ms 1804 KB Output is correct
23 Correct 22 ms 1884 KB Output is correct
24 Correct 29 ms 2700 KB Output is correct
25 Correct 85 ms 11852 KB Output is correct
26 Correct 83 ms 11808 KB Output is correct
27 Correct 75 ms 11428 KB Output is correct
28 Correct 80 ms 11680 KB Output is correct
29 Correct 88 ms 11076 KB Output is correct
30 Correct 83 ms 10436 KB Output is correct
31 Correct 69 ms 9892 KB Output is correct
32 Correct 58 ms 10016 KB Output is correct
33 Correct 9 ms 1492 KB Output is correct
34 Correct 80 ms 12196 KB Output is correct
35 Correct 73 ms 11568 KB Output is correct
36 Correct 83 ms 11832 KB Output is correct
37 Correct 78 ms 11556 KB Output is correct
38 Correct 77 ms 11444 KB Output is correct
39 Correct 81 ms 11684 KB Output is correct
40 Correct 82 ms 11688 KB Output is correct
41 Correct 26 ms 3028 KB Output is correct
42 Correct 66 ms 10088 KB Output is correct
43 Correct 76 ms 13316 KB Output is correct
44 Correct 30 ms 2924 KB Output is correct
45 Correct 72 ms 11604 KB Output is correct
46 Correct 80 ms 13472 KB Output is correct
47 Correct 87 ms 13740 KB Output is correct
48 Correct 87 ms 13736 KB Output is correct