# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1016260 |
2024-07-07T15:11:43 Z |
ZeroCool |
Snowball (JOI21_ho_t2) |
C++14 |
|
1 ms |
388 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
#define int long long
const int N = 5e5 + 20;
const int INF = 1e17;
const int MOD = 8;
const int X = 4000;
const int LOG = 21;
//#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
//#pragma GCC optimize("O3")
signed main(){ios_base::sync_with_stdio(false);cin.tie(0);
int n, q;
cin>>n>>q;
int A[n];
for(int i = 0;i < n;i++)cin>>A[i];
int mn[q], mx[q];
int sum = 0;
for(int i = 0;i < q;i++){
int x;
cin>>x;
sum += x;
mn[i] = min((i ? mn[i-1] : 0), sum);
mx[i] = max((i ? mx[i-1] : 0), sum);
}
int ans[n];
memset(ans, 0,sizeof ans);
ans[0] = abs(mn[q-1]);
ans[n-1] = mx[q-1];
for(int i = 1;i < n;i++){
int lo = 0;
int res = 0;
int hi = q-1;
while(lo <= hi){
int mid = (lo + hi) / 2;
if(A[i] - A[i-1] > mx[mid] - mn[mid]){
res = mid;
lo = mid + 1;
}else hi = mid - 1;
}
ans[i-1 ] += mx[res];
if(res + 1 < q && mx[res + 1] > mx[res]){
ans[i-1] += A[i] - A[i-1] - (mx[res] - mn[res]);
}
else if(res + 1 < q){
ans[i] += A[i] - A[i-1] - (mx[res] - mn[res]);
}
ans[i] += abs(mn[res]);
}
for(int i = 0;i < n;i++)cout<<ans[i]<<" ";
}
# |
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 |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 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 |
388 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 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 |
388 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |