# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
758795 |
2023-06-15T10:13:09 Z |
nihon |
Snowball (JOI21_ho_t2) |
C++14 |
|
168 ms |
16952 KB |
#include <bits/stdc++.h>
#define ll long long
#define N 200005
using namespace std;
ll n,q,x,i,st,dr,mid,sol,l;
ll v[N],s[N],mn[N],mx[N],k[N],g[N];
int main()
{
cin>>n>>q;
for(i=1;i<=n;++i)
{
cin>>v[i];
}
for(i=1;i<=q;++i)
{
cin>>x;
s[i]=s[i-1]+x;
mn[i]=min(mn[i-1],s[i]);
mx[i]=max(mx[i-1],s[i]);
k[i]=abs(mn[i])+mx[i];
}
for(i=1;i<n;++i)
{
st=1; dr=q;
sol=q;
l=v[i+1]-v[i];
while(st<=dr)
{
mid=(st+dr)>>1;
if(l>k[mid]) st=mid+1;
else {sol=mid; dr=mid-1;}
}
if(k[sol]<l)
{
g[i]+=mx[sol];
g[i+1]+=abs(mn[sol]);
}
else
{
g[i]+=mx[sol-1];
g[i+1]+=abs(mn[sol-1]);
if(mx[sol]>mx[sol-1])
{
g[i]+=l-k[sol-1];
}
else
{
g[i+1]+=l-k[sol-1];
}
}
}
g[1]+=abs(mn[q]);
g[n]+=mx[q];
for(i=1;i<=n;++i)
{
cout<<g[i]<<'\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
400 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
448 KB |
Output is correct |
6 |
Correct |
2 ms |
484 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
452 KB |
Output is correct |
10 |
Correct |
2 ms |
452 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
400 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
448 KB |
Output is correct |
6 |
Correct |
2 ms |
484 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
452 KB |
Output is correct |
10 |
Correct |
2 ms |
452 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
468 KB |
Output is correct |
20 |
Correct |
63 ms |
8600 KB |
Output is correct |
21 |
Correct |
58 ms |
8384 KB |
Output is correct |
22 |
Correct |
54 ms |
8232 KB |
Output is correct |
23 |
Correct |
51 ms |
8136 KB |
Output is correct |
24 |
Correct |
58 ms |
8564 KB |
Output is correct |
25 |
Correct |
151 ms |
14944 KB |
Output is correct |
26 |
Correct |
151 ms |
14796 KB |
Output is correct |
27 |
Correct |
146 ms |
14580 KB |
Output is correct |
28 |
Correct |
155 ms |
14748 KB |
Output is correct |
29 |
Correct |
144 ms |
14196 KB |
Output is correct |
30 |
Correct |
135 ms |
13516 KB |
Output is correct |
31 |
Correct |
111 ms |
13060 KB |
Output is correct |
32 |
Correct |
113 ms |
13156 KB |
Output is correct |
33 |
Correct |
16 ms |
1836 KB |
Output is correct |
34 |
Correct |
157 ms |
15344 KB |
Output is correct |
35 |
Correct |
151 ms |
14656 KB |
Output is correct |
36 |
Correct |
157 ms |
15012 KB |
Output is correct |
37 |
Correct |
153 ms |
14640 KB |
Output is correct |
38 |
Correct |
145 ms |
14584 KB |
Output is correct |
39 |
Correct |
154 ms |
14828 KB |
Output is correct |
40 |
Correct |
130 ms |
14672 KB |
Output is correct |
41 |
Correct |
73 ms |
9200 KB |
Output is correct |
42 |
Correct |
112 ms |
13092 KB |
Output is correct |
43 |
Correct |
166 ms |
16608 KB |
Output is correct |
44 |
Correct |
73 ms |
9056 KB |
Output is correct |
45 |
Correct |
125 ms |
14728 KB |
Output is correct |
46 |
Correct |
158 ms |
16584 KB |
Output is correct |
47 |
Correct |
168 ms |
16952 KB |
Output is correct |
48 |
Correct |
164 ms |
16828 KB |
Output is correct |