# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
709500 |
2023-03-13T18:01:31 Z |
sofija6 |
Snowball (JOI21_ho_t2) |
C++14 |
|
795 ms |
12348 KB |
#include <bits/stdc++.h>
#define ll long long
#define MAXN 200010
using namespace std;
ll n,q,x[MAXN],maxx[MAXN],minn[MAXN];
bool Check_1(ll d,ll pos)
{
ll l=0,r=q,mid,p=0;
while (l<=r)
{
mid=(l+r)/2;
if (maxx[mid]>=d)
{
p=mid;
r=mid-1;
}
else
l=mid+1;
}
return (pos==n || x[pos]+d<=x[pos+1]+minn[p]);
}
bool Check_2(ll d,ll pos)
{
ll l=0,r=q,mid,p=0;
while (l<=r)
{
mid=(l+r)/2;
if (minn[mid]<=d)
{
p=mid;
r=mid-1;
}
else
l=mid+1;
}
return (pos==1 || x[pos]+d>=x[pos-1]+maxx[p]);
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll a,cur=0;
cin >> n >> q;
for (ll i=1;i<=n;i++)
cin >> x[i];
for (ll i=1;i<=q;i++)
{
cin >> a;
cur+=a;
maxx[i]=max(maxx[i-1],cur);
minn[i]=min(minn[i-1],cur);
}
for (ll i=1;i<=n;i++)
{
ll L=0,R=0,l=0,r=maxx[q],mid;
while (l<=r)
{
mid=(l+r)/2;
if (Check_1(mid,i))
{
R=mid;
l=mid+1;
}
else
r=mid-1;
}
l=minn[q];
r=0;
while (l<=r)
{
mid=(l+r)/2;
if (Check_2(mid,i))
{
L=mid;
r=mid-1;
}
else
l=mid+1;
}
cout << R-L << "\n";
}
return 0;
}
# |
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 |
336 KB |
Output is correct |
4 |
Correct |
6 ms |
340 KB |
Output is correct |
5 |
Correct |
5 ms |
340 KB |
Output is correct |
6 |
Correct |
4 ms |
340 KB |
Output is correct |
7 |
Correct |
4 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
340 KB |
Output is correct |
9 |
Correct |
2 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 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
6 ms |
340 KB |
Output is correct |
16 |
Correct |
5 ms |
340 KB |
Output is correct |
17 |
Correct |
4 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
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 |
336 KB |
Output is correct |
4 |
Correct |
6 ms |
340 KB |
Output is correct |
5 |
Correct |
5 ms |
340 KB |
Output is correct |
6 |
Correct |
4 ms |
340 KB |
Output is correct |
7 |
Correct |
4 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
340 KB |
Output is correct |
9 |
Correct |
2 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 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
6 ms |
340 KB |
Output is correct |
16 |
Correct |
5 ms |
340 KB |
Output is correct |
17 |
Correct |
4 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
34 ms |
5452 KB |
Output is correct |
21 |
Correct |
25 ms |
5260 KB |
Output is correct |
22 |
Correct |
27 ms |
5192 KB |
Output is correct |
23 |
Correct |
32 ms |
4936 KB |
Output is correct |
24 |
Correct |
105 ms |
5284 KB |
Output is correct |
25 |
Correct |
793 ms |
10320 KB |
Output is correct |
26 |
Correct |
790 ms |
10160 KB |
Output is correct |
27 |
Correct |
716 ms |
9812 KB |
Output is correct |
28 |
Correct |
719 ms |
10032 KB |
Output is correct |
29 |
Correct |
628 ms |
9524 KB |
Output is correct |
30 |
Correct |
274 ms |
8852 KB |
Output is correct |
31 |
Correct |
92 ms |
8372 KB |
Output is correct |
32 |
Correct |
67 ms |
8428 KB |
Output is correct |
33 |
Correct |
67 ms |
1288 KB |
Output is correct |
34 |
Correct |
758 ms |
10792 KB |
Output is correct |
35 |
Correct |
709 ms |
10156 KB |
Output is correct |
36 |
Correct |
795 ms |
10316 KB |
Output is correct |
37 |
Correct |
692 ms |
10000 KB |
Output is correct |
38 |
Correct |
704 ms |
9836 KB |
Output is correct |
39 |
Correct |
739 ms |
10116 KB |
Output is correct |
40 |
Correct |
353 ms |
10060 KB |
Output is correct |
41 |
Correct |
34 ms |
6168 KB |
Output is correct |
42 |
Correct |
60 ms |
8608 KB |
Output is correct |
43 |
Correct |
417 ms |
11848 KB |
Output is correct |
44 |
Correct |
30 ms |
6004 KB |
Output is correct |
45 |
Correct |
248 ms |
10024 KB |
Output is correct |
46 |
Correct |
326 ms |
11964 KB |
Output is correct |
47 |
Correct |
523 ms |
12148 KB |
Output is correct |
48 |
Correct |
327 ms |
12348 KB |
Output is correct |