# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
893837 |
2023-12-27T14:16:23 Z |
hafo |
Snowball (JOI21_ho_t2) |
C++14 |
|
88 ms |
14788 KB |
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define pa pair<int, int>
#define pall pair<ll, int>
#define fi first
#define se second
#define TASK "test"
#define Size(x) (int) x.size()
#define all(x) x.begin(), x.end()
using namespace std;
template<typename T1, typename T2> bool mini (T1 &a, T2 b) {if(a > b) a = b; else return 0; return 1;}
template<typename T1, typename T2> bool maxi (T1 &a, T2 b) {if(a < b) a = b; else return 0; return 1;}
const int MOD = 1e9 + 7;
const int LOG = 20;
const int maxn = 2e5 + 7;
const ll oo = 1e18 + 69;
int n, q;
bool ok[maxn][2];
ll x[maxn], w, res[maxn];
vector<pall> val;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen(TASK".inp", "r", stdin);
//freopen(TASK".out", "w", stdout);
cin>>n>>q;
for(int i = 1; i <= n; i++) cin>>x[i];
for(int i = 2; i <= n; i++) val.pb({x[i] - x[i - 1], i});
sort(all(val));
ll l = 0, r = 0, cnt = 0;
int i = 0;
while(q--) {
cin>>w;
cnt += w;
if(cnt > 0) maxi(r, cnt);
if(cnt < 0) maxi(l, -cnt);
while(i < Size(val) && val[i].fi <= l + r) {
int j = val[i].se - 1;
if(cnt > 0) {
ok[j][1] = 1;
ok[j + 1][0] = 1;
res[j] += val[i].fi - l;
res[j + 1] += l;
} else {
ok[j][1] = 1;
ok[j + 1][0] = 1;
res[j] += r;
res[j + 1] += val[i].fi - r;
}
i++;
}
}
for(int i = 1; i <= n; i++) {
if(!ok[i][0]) res[i] += l;
if(!ok[i][1]) res[i] += r;
cout<<res[i]<<"\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
2 ms |
2652 KB |
Output is correct |
5 |
Correct |
2 ms |
2648 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
9 |
Correct |
1 ms |
2400 KB |
Output is correct |
10 |
Correct |
1 ms |
2400 KB |
Output is correct |
11 |
Correct |
1 ms |
2552 KB |
Output is correct |
12 |
Correct |
1 ms |
2400 KB |
Output is correct |
13 |
Correct |
1 ms |
2400 KB |
Output is correct |
14 |
Correct |
1 ms |
2652 KB |
Output is correct |
15 |
Correct |
2 ms |
2656 KB |
Output is correct |
16 |
Correct |
2 ms |
2656 KB |
Output is correct |
17 |
Correct |
2 ms |
2656 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
2 ms |
2652 KB |
Output is correct |
5 |
Correct |
2 ms |
2648 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
9 |
Correct |
1 ms |
2400 KB |
Output is correct |
10 |
Correct |
1 ms |
2400 KB |
Output is correct |
11 |
Correct |
1 ms |
2552 KB |
Output is correct |
12 |
Correct |
1 ms |
2400 KB |
Output is correct |
13 |
Correct |
1 ms |
2400 KB |
Output is correct |
14 |
Correct |
1 ms |
2652 KB |
Output is correct |
15 |
Correct |
2 ms |
2656 KB |
Output is correct |
16 |
Correct |
2 ms |
2656 KB |
Output is correct |
17 |
Correct |
2 ms |
2656 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
2396 KB |
Output is correct |
20 |
Correct |
19 ms |
4420 KB |
Output is correct |
21 |
Correct |
19 ms |
4448 KB |
Output is correct |
22 |
Correct |
17 ms |
4192 KB |
Output is correct |
23 |
Correct |
17 ms |
4364 KB |
Output is correct |
24 |
Correct |
22 ms |
4816 KB |
Output is correct |
25 |
Correct |
74 ms |
12880 KB |
Output is correct |
26 |
Correct |
66 ms |
12488 KB |
Output is correct |
27 |
Correct |
65 ms |
12228 KB |
Output is correct |
28 |
Correct |
65 ms |
12228 KB |
Output is correct |
29 |
Correct |
65 ms |
11716 KB |
Output is correct |
30 |
Correct |
64 ms |
10976 KB |
Output is correct |
31 |
Correct |
59 ms |
10952 KB |
Output is correct |
32 |
Correct |
64 ms |
11976 KB |
Output is correct |
33 |
Correct |
9 ms |
3548 KB |
Output is correct |
34 |
Correct |
71 ms |
13084 KB |
Output is correct |
35 |
Correct |
73 ms |
12636 KB |
Output is correct |
36 |
Correct |
68 ms |
12460 KB |
Output is correct |
37 |
Correct |
81 ms |
12280 KB |
Output is correct |
38 |
Correct |
68 ms |
12128 KB |
Output is correct |
39 |
Correct |
66 ms |
12992 KB |
Output is correct |
40 |
Correct |
65 ms |
12508 KB |
Output is correct |
41 |
Correct |
24 ms |
5204 KB |
Output is correct |
42 |
Correct |
56 ms |
12368 KB |
Output is correct |
43 |
Correct |
60 ms |
14788 KB |
Output is correct |
44 |
Correct |
19 ms |
4956 KB |
Output is correct |
45 |
Correct |
88 ms |
12296 KB |
Output is correct |
46 |
Correct |
66 ms |
14576 KB |
Output is correct |
47 |
Correct |
63 ms |
14548 KB |
Output is correct |
48 |
Correct |
75 ms |
14396 KB |
Output is correct |