# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
563575 |
2022-05-17T15:01:27 Z |
groshi |
Snowball (JOI21_ho_t2) |
C++17 |
|
96 ms |
13924 KB |
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
vector<pair<long long,int> > Q;
long long t[300000];
long long odp[300000];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,q;
long long x;
cin>>n>>q;
t[0]=-1e18;
for(int i=1;i<=n;i++)
{
cin>>x;
t[i]=x;
}
t[n+1]=1e18;
for(int i=1;i<=n+1;i++)
Q.push_back({t[i]-t[i-1],i});
sort(Q.begin(),Q.end());
long long l=0,r=0,gdzie=0,wskaz=0;
while(q--)
{
cin>>x;
gdzie+=x;
r=max(r,gdzie);
l=min(l,gdzie);
if(x<=0)
{
while(Q[wskaz].first<=r-l)
{
odp[Q[wskaz].second-1]+=r;
odp[Q[wskaz].second]+=(Q[wskaz].first-r);
wskaz++;
}
}
else{
while(Q[wskaz].first<=r-l)
{
odp[Q[wskaz].second]+=(-l);
odp[Q[wskaz].second-1]+=(Q[wskaz].first-(-l));
wskaz++;
}
}
}
while(wskaz<Q.size())
{
odp[Q[wskaz].second-1]+=r;
odp[Q[wskaz].second]+=(-l);
wskaz++;
}
for(int i=1;i<=n;i++)
cout<<odp[i]<<"\n";
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:52:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | while(wskaz<Q.size())
| ~~~~~^~~~~~~~~
# |
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 |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
472 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
464 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
212 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 |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
472 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
464 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
27 ms |
2360 KB |
Output is correct |
21 |
Correct |
26 ms |
2232 KB |
Output is correct |
22 |
Correct |
24 ms |
1980 KB |
Output is correct |
23 |
Correct |
22 ms |
1940 KB |
Output is correct |
24 |
Correct |
27 ms |
2828 KB |
Output is correct |
25 |
Correct |
84 ms |
11952 KB |
Output is correct |
26 |
Correct |
79 ms |
11924 KB |
Output is correct |
27 |
Correct |
79 ms |
11544 KB |
Output is correct |
28 |
Correct |
83 ms |
11740 KB |
Output is correct |
29 |
Correct |
80 ms |
11232 KB |
Output is correct |
30 |
Correct |
75 ms |
10632 KB |
Output is correct |
31 |
Correct |
77 ms |
10040 KB |
Output is correct |
32 |
Correct |
61 ms |
10268 KB |
Output is correct |
33 |
Correct |
9 ms |
1644 KB |
Output is correct |
34 |
Correct |
83 ms |
12324 KB |
Output is correct |
35 |
Correct |
78 ms |
11712 KB |
Output is correct |
36 |
Correct |
81 ms |
12004 KB |
Output is correct |
37 |
Correct |
81 ms |
11708 KB |
Output is correct |
38 |
Correct |
96 ms |
11516 KB |
Output is correct |
39 |
Correct |
84 ms |
11792 KB |
Output is correct |
40 |
Correct |
82 ms |
11784 KB |
Output is correct |
41 |
Correct |
27 ms |
2988 KB |
Output is correct |
42 |
Correct |
74 ms |
10124 KB |
Output is correct |
43 |
Correct |
94 ms |
13484 KB |
Output is correct |
44 |
Correct |
29 ms |
2892 KB |
Output is correct |
45 |
Correct |
78 ms |
11668 KB |
Output is correct |
46 |
Correct |
85 ms |
13588 KB |
Output is correct |
47 |
Correct |
84 ms |
13876 KB |
Output is correct |
48 |
Correct |
85 ms |
13924 KB |
Output is correct |