# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
167314 |
2019-12-07T09:38:46 Z |
itgl |
Schools (IZhO13_school) |
C++14 |
|
443 ms |
11520 KB |
#include<bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
using namespace std;
priority_queue<pair<int,pair<int,int> > > pq,pq1;
priority_queue<int> pq_m,pq_s;
int main(){
int n,m,s;
cin >> n >> m >> s;
for(int i=1;i<=n;i++){
int x,y;
cin >> x >> y;
pq.push(mp(x-y,mp(x,y)));
}
int res=0;
while(m--){
res+=pq.top().ss.ff;
pq_m.push(-pq.top().ss.ff);
pq.pop();
}
int k=pq.size();
while(k--){
pq1.push(mp(-pq.top().ff,mp(pq.top().ss.ff,pq.top().ss.ss)));
pq.pop();
}
while(s--){
res+=pq1.top().ss.ss;
pq_s.push(-pq1.top().ss.ss);
pq1.pop();
}
while(!pq1.empty()){
int x1,y1;
x1=-pq_m.top();
y1=-pq_s.top();
if(pq1.top().ss.ff-x1>0){
if(pq1.top().ss.ff-x1>pq1.top().ss.ss-y1){
res+=pq1.top().ss.ff-x1;
pq_m.pop();
pq_m.push(-pq1.top().ss.ff);
}
else{
res+=pq1.top().ss.ss-y1;
pq_s.pop();
pq_s.push(-pq1.top().ss.ss);
}
}else{
if(pq1.top().ss.ss-y1>0){
res+=pq1.top().ss.ss-y1;
pq_s.pop();
pq_s.push(-pq1.top().ss.ss);
}
}
pq1.pop();
}
cout <<res;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
7 |
Incorrect |
8 ms |
504 KB |
Output isn't correct |
8 |
Correct |
8 ms |
504 KB |
Output is correct |
9 |
Incorrect |
8 ms |
632 KB |
Output isn't correct |
10 |
Incorrect |
8 ms |
508 KB |
Output isn't correct |
11 |
Incorrect |
9 ms |
632 KB |
Output isn't correct |
12 |
Incorrect |
9 ms |
632 KB |
Output isn't correct |
13 |
Incorrect |
47 ms |
1652 KB |
Output isn't correct |
14 |
Incorrect |
112 ms |
4432 KB |
Output isn't correct |
15 |
Incorrect |
227 ms |
8612 KB |
Output isn't correct |
16 |
Incorrect |
256 ms |
8844 KB |
Output isn't correct |
17 |
Incorrect |
325 ms |
9616 KB |
Output isn't correct |
18 |
Incorrect |
348 ms |
10080 KB |
Output isn't correct |
19 |
Incorrect |
382 ms |
10584 KB |
Output isn't correct |
20 |
Incorrect |
443 ms |
11520 KB |
Output isn't correct |