# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
543263 |
2022-03-30T02:20:57 Z |
Fysty |
Snowball (JOI21_ho_t2) |
C++17 |
|
156 ms |
16980 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
//#define int ll
#define MottoHayaku ios::sync_with_stdio(0);cin.tie(0);
#define F first
#define S second
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define uni(c) c.resize(distance(c.begin(),unique(c.begin(),c.end())))
#define unisort(c) sort(c.begin(),c.end());uni(c);
#define X first
#define Y second
const int N=2e5+5;
ll x[N],l[N],r[N];
signed main()
{
MottoHayaku
ll n,q;
cin>>n>>q;
rep1(i,n) cin>>x[i];
vector<ll> mn(q+1,0),mx(q+1,0),d(q+1,0);
ll cur=0;
rep1(i,q)
{
ll w;
cin>>w;
cur+=w;
mn[i]=max(mn[i-1],-cur);
mx[i]=max(mx[i-1],cur);
d[i]=mx[i]+mn[i];
}
l[1]=x[1]-mn[q];
r[n]=x[n]+mx[q];
rep1(i,n-1)
{
ll z=x[i+1]-x[i];
ll pos=lower_bound(d.begin(),d.end(),z)-d.begin();
if(pos==d.size())
{
r[i]=x[i]+mx[q];
l[i+1]=x[i+1]-mn[q];
continue;
}
ll tmx=mx[pos],tmn=mn[pos];
ll pmx=lower_bound(mx.begin(),mx.end(),tmx)-mx.begin();
ll pmn=lower_bound(mn.begin(),mn.end(),tmn)-mn.begin();
if(pmn<pmx) l[i+1]=r[i]=x[i+1]-tmn;
else r[i]=l[i+1]=x[i]+tmx;
}
rep1(i,n) cout<<r[i]-l[i]<<"\n";
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:42:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | if(pos==d.size())
| ~~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
412 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
464 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 |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
224 KB |
Output is correct |
13 |
Correct |
0 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
2 ms |
464 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
472 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
19 |
Correct |
1 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 |
412 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
464 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 |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
224 KB |
Output is correct |
13 |
Correct |
0 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
2 ms |
464 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
472 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
28 ms |
7064 KB |
Output is correct |
21 |
Correct |
27 ms |
6940 KB |
Output is correct |
22 |
Correct |
27 ms |
6704 KB |
Output is correct |
23 |
Correct |
25 ms |
6580 KB |
Output is correct |
24 |
Correct |
37 ms |
7244 KB |
Output is correct |
25 |
Correct |
149 ms |
14936 KB |
Output is correct |
26 |
Correct |
152 ms |
14868 KB |
Output is correct |
27 |
Correct |
146 ms |
14608 KB |
Output is correct |
28 |
Correct |
149 ms |
14700 KB |
Output is correct |
29 |
Correct |
151 ms |
14296 KB |
Output is correct |
30 |
Correct |
136 ms |
13680 KB |
Output is correct |
31 |
Correct |
66 ms |
13132 KB |
Output is correct |
32 |
Correct |
61 ms |
13260 KB |
Output is correct |
33 |
Correct |
16 ms |
1876 KB |
Output is correct |
34 |
Correct |
156 ms |
15308 KB |
Output is correct |
35 |
Correct |
156 ms |
14768 KB |
Output is correct |
36 |
Correct |
145 ms |
14924 KB |
Output is correct |
37 |
Correct |
145 ms |
14680 KB |
Output is correct |
38 |
Correct |
147 ms |
14540 KB |
Output is correct |
39 |
Correct |
136 ms |
14740 KB |
Output is correct |
40 |
Correct |
75 ms |
14792 KB |
Output is correct |
41 |
Correct |
30 ms |
7704 KB |
Output is correct |
42 |
Correct |
57 ms |
13132 KB |
Output is correct |
43 |
Correct |
83 ms |
16652 KB |
Output is correct |
44 |
Correct |
33 ms |
7632 KB |
Output is correct |
45 |
Correct |
62 ms |
14768 KB |
Output is correct |
46 |
Correct |
90 ms |
16660 KB |
Output is correct |
47 |
Correct |
94 ms |
16848 KB |
Output is correct |
48 |
Correct |
91 ms |
16980 KB |
Output is correct |