# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
862010 |
2023-10-17T11:23:24 Z |
8pete8 |
Snowball (JOI21_ho_t2) |
C++14 |
|
2 ms |
528 KB |
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<bitset>
#include<stack>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define pppiiii pair<pii,pii>
#define ppii pair<int,pii>
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
const int mxn=5e5+10,mx=5e6+10,minf=-1e9;
int32_t main(){
int n,q;cin>>n>>q;
vector<int>pos(n),ans(n,0);
for(int i=0;i<n;i++)cin>>pos[i];
vector<int>mn(q,0),mx(q,0);
int cur=0;
for(int i=1;i<=q;i++){
int k;cin>>k;
cur+=k;
if(i)mn[i]=mn[i-1],mx[i]=mx[i-1];
mn[i]=min(mn[i],cur);
mx[i]=max(mx[i],cur);
}
ans[0]-=mn[q];
ans[n-1]+=mx[q];
for(int i=0;i<n-1;i++){
int l=0,r=q,a=0;
while(l<=r){
int mid=l+(r-l)/2;
if(pos[i+1]+mn[mid]>pos[i]+mx[mid]){
a=max(a,mid);
l=mid+1;
}
else r=mid-1;
}
ans[i]+=mx[a];
ans[i+1]-=mn[a];
if(a<q){
int diff=(pos[i+1]+mn[a])-(pos[i]+mx[a]);
if(mx[a+1]>mx[a])ans[i]+=diff;
else ans[i+1]+=diff;
}
}
for(auto i:ans)cout<<i<<'\n';
}
/*
4 5 3 100
2 80 100
5 125 130
4 75 150
3 120 110
*/
# |
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 |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
452 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
528 KB |
Output is correct |
12 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
13 |
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 |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
452 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
528 KB |
Output is correct |
12 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
13 |
Halted |
0 ms |
0 KB |
- |