# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
677773 |
2023-01-04T10:57:22 Z |
rittin1 |
Snowball (JOI21_ho_t2) |
C++17 |
|
2 ms |
468 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,q;
cin >> n >> q;
int pos[n+1];
for(int i=1;i<=n;i++){
cin >> pos[i];
}
int w[q+2];
w[q+1]=0;
w[0]=0;
int x;
int a[q+2];
a[q+1]=(long long)1e18;
//a[0]=0;
int mx[q+1];
int mn[q+1];
mn[0]=0;
mx[0]=0;
for(int i=1;i<=q;i++){
cin >> x;
w[i]=w[i-1]+x;
mn[i]=min(mn[i-1],w[i]);
mx[i]=max(mx[i-1],w[i]);
a[i]=mx[i]-mn[i];
}
int ans[n+1];
for(int i=1;i<=n;i++){
ans[i]=0;
}
ans[1]+=(-mn[q]);
for(int i=1;i<n;i++){
int diff=pos[i+1]-pos[i];
int ind=lower_bound(a,a+q+2,diff)-a;
//cout << ind << '\n';
if(ind!=0){
if(ind>q){
ans[i]+=(mx[q]);
ans[i+1]+=(-mn[q]);
}
else{
ind--;
ans[i]+=(mx[ind]);
ans[i+1]+=(-mn[ind]);
if(w[ind+1]<w[ind]){
ans[i+1]+=pos[i+1]-pos[i]-a[ind];
}
else{
ans[i]+=pos[i+1]-pos[i]-a[ind];
}
}
}
}
ans[n]+=mx[q];
for(int i=1;i<=n;i++){
cout << ans[i] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
400 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
400 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |