# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1114152 |
2024-11-18T08:54:36 Z |
Dan4Life |
Snowball (JOI21_ho_t2) |
C++17 |
|
2500 ms |
6908 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
#define int long long
const int N = (int)2e5+10;
const int LINF = (int)1e18;
int n, q, a[N], w[N];
using ar2 = array<int,2>;
ar2 xd[N];
ar2 f(int dis){
int a = 0, b = dis, mnB=dis, mxA = 0;
for(int i = 0; i < q; i++){
if(!w[i]) continue;
a+=w[i]; b+=w[i];
if(a>mnB) a=mnB;
if(b<mxA) b=mxA;
mxA = max(mxA, a);
mnB = min(mnB, b);
if(mxA>=mnB) break;
}
return {mxA,dis-mnB};
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> q; a[0] = -LINF; a[n+1]=LINF;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 0; i < q; i++) cin >> w[i];
for(int i = 1; i <= n+1; i++) xd[i] = f(a[i]-a[i-1]);
for(int i = 1; i <= n; i++) cout << xd[i][1]+xd[i+1][0] << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
2 ms |
2552 KB |
Output is correct |
3 |
Correct |
2 ms |
2384 KB |
Output is correct |
4 |
Correct |
5 ms |
2716 KB |
Output is correct |
5 |
Correct |
4 ms |
2384 KB |
Output is correct |
6 |
Correct |
5 ms |
2384 KB |
Output is correct |
7 |
Correct |
6 ms |
2740 KB |
Output is correct |
8 |
Correct |
5 ms |
2384 KB |
Output is correct |
9 |
Correct |
4 ms |
2384 KB |
Output is correct |
10 |
Correct |
4 ms |
2384 KB |
Output is correct |
11 |
Correct |
3 ms |
2384 KB |
Output is correct |
12 |
Correct |
1 ms |
2384 KB |
Output is correct |
13 |
Correct |
1 ms |
2384 KB |
Output is correct |
14 |
Correct |
1 ms |
2524 KB |
Output is correct |
15 |
Correct |
5 ms |
2640 KB |
Output is correct |
16 |
Correct |
5 ms |
2384 KB |
Output is correct |
17 |
Correct |
4 ms |
2556 KB |
Output is correct |
18 |
Correct |
1 ms |
2384 KB |
Output is correct |
19 |
Correct |
5 ms |
2384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
2 ms |
2552 KB |
Output is correct |
3 |
Correct |
2 ms |
2384 KB |
Output is correct |
4 |
Correct |
5 ms |
2716 KB |
Output is correct |
5 |
Correct |
4 ms |
2384 KB |
Output is correct |
6 |
Correct |
5 ms |
2384 KB |
Output is correct |
7 |
Correct |
6 ms |
2740 KB |
Output is correct |
8 |
Correct |
5 ms |
2384 KB |
Output is correct |
9 |
Correct |
4 ms |
2384 KB |
Output is correct |
10 |
Correct |
4 ms |
2384 KB |
Output is correct |
11 |
Correct |
3 ms |
2384 KB |
Output is correct |
12 |
Correct |
1 ms |
2384 KB |
Output is correct |
13 |
Correct |
1 ms |
2384 KB |
Output is correct |
14 |
Correct |
1 ms |
2524 KB |
Output is correct |
15 |
Correct |
5 ms |
2640 KB |
Output is correct |
16 |
Correct |
5 ms |
2384 KB |
Output is correct |
17 |
Correct |
4 ms |
2556 KB |
Output is correct |
18 |
Correct |
1 ms |
2384 KB |
Output is correct |
19 |
Correct |
5 ms |
2384 KB |
Output is correct |
20 |
Correct |
23 ms |
4940 KB |
Output is correct |
21 |
Correct |
28 ms |
4816 KB |
Output is correct |
22 |
Correct |
45 ms |
4688 KB |
Output is correct |
23 |
Correct |
309 ms |
4432 KB |
Output is correct |
24 |
Execution timed out |
2547 ms |
6908 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |