# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
635428 |
2022-08-26T08:56:03 Z |
groshi |
Snowball (JOI21_ho_t2) |
C++17 |
|
138 ms |
16928 KB |
//Karol Zeleznik
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
pair<ll,ll>t[200010];
//to co odejmuje
vector<ll>v;
//wejscie
priority_queue< pair<ll,ll> >p;
priority_queue< pair<ll,ll> >l;
//kolejki minimalne roznice na prawo i na lewo
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n,q,v1,akt=0,mnl=0,mnp=0,as;
// n,q,v1,aktualna pozycja,max na lewo i prawo
cin>>n>>q;
for(int i=0;i<n;i++){
cin>>v1;
v.push_back(v1);
t[i].first=1e18;
t[i].second=1e18;
}
for(int i=0;i<v.size();i++){
if(i!=n-1)p.push({-v[i+1]+v[i],i});
if(i!=0)l.push({-v[i]+v[i-1],i});
}
p.push({-1e18,n-1});
l.push({-1e18,0});
while(q--){
cin>>v1;
akt+=v1;
//cout<<akt<<'\n';
if(akt>mnp){
while(-p.top().first+mnl<akt){
t[p.top().second].second=max(mnp,-p.top().first+mnl);
//cout<<-p.top().first+mnl<<'\n';
p.pop();
}
mnp=akt;
}
if(akt<mnl){
while(-l.top().first-mnp<-akt){
t[l.top().second].first=max(-mnl,-l.top().first-mnp);
//cout<<t[l.top().second].first<<'\n';
l.pop();
}
mnl=akt;
}
}
//cout<<"\ndla 3 odp to: "<<t[2].first<<" + "<<t[2].second<<'\n';
for(int i=0;i<n;i++){
as=0;
if(t[i].first==1e18)as-=mnl;
else as+=t[i].first;
if(t[i].second==1e18)as+=mnp;
else as+=t[i].second;
cout<<as<<'\n';
}
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i=0;i<v.size();i++){
| ~^~~~~~~~~
# |
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 |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
520 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
472 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
472 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
0 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
472 KB |
Output is correct |
16 |
Correct |
2 ms |
472 KB |
Output is correct |
17 |
Correct |
2 ms |
468 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 |
340 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 |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
520 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
472 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
472 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
0 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
472 KB |
Output is correct |
16 |
Correct |
2 ms |
472 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
34 ms |
1364 KB |
Output is correct |
21 |
Correct |
25 ms |
1344 KB |
Output is correct |
22 |
Correct |
24 ms |
1364 KB |
Output is correct |
23 |
Correct |
21 ms |
912 KB |
Output is correct |
24 |
Correct |
27 ms |
2260 KB |
Output is correct |
25 |
Correct |
132 ms |
16760 KB |
Output is correct |
26 |
Correct |
137 ms |
16828 KB |
Output is correct |
27 |
Correct |
121 ms |
16536 KB |
Output is correct |
28 |
Correct |
127 ms |
16600 KB |
Output is correct |
29 |
Correct |
132 ms |
16400 KB |
Output is correct |
30 |
Correct |
124 ms |
15900 KB |
Output is correct |
31 |
Correct |
98 ms |
15548 KB |
Output is correct |
32 |
Correct |
80 ms |
15576 KB |
Output is correct |
33 |
Correct |
12 ms |
2348 KB |
Output is correct |
34 |
Correct |
131 ms |
16760 KB |
Output is correct |
35 |
Correct |
121 ms |
16524 KB |
Output is correct |
36 |
Correct |
138 ms |
16776 KB |
Output is correct |
37 |
Correct |
124 ms |
16512 KB |
Output is correct |
38 |
Correct |
122 ms |
16572 KB |
Output is correct |
39 |
Correct |
138 ms |
16504 KB |
Output is correct |
40 |
Correct |
124 ms |
16500 KB |
Output is correct |
41 |
Correct |
33 ms |
720 KB |
Output is correct |
42 |
Correct |
62 ms |
15548 KB |
Output is correct |
43 |
Correct |
106 ms |
16704 KB |
Output is correct |
44 |
Correct |
26 ms |
700 KB |
Output is correct |
45 |
Correct |
76 ms |
16616 KB |
Output is correct |
46 |
Correct |
111 ms |
16916 KB |
Output is correct |
47 |
Correct |
110 ms |
16884 KB |
Output is correct |
48 |
Correct |
96 ms |
16928 KB |
Output is correct |