Submission #167091

# Submission time Handle Problem Language Result Execution time Memory
167091 2019-12-05T14:16:41 Z itgl Schools (IZhO13_school) C++14
30 / 100
457 ms 9908 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;
  //cout << "==================\n";
  while(m--){
    //cout << pq.top().ss.ff << ' ' << pq.top().ss.ss << '\n';
    res+=pq.top().ss.ff;
    pq_m.push(-pq.top().ss.ff);
    pq.pop();
  }
  //cout<<"====================\n";
  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--){
    //cout << pq1.top().ss.ff << ' ' << pq1.top().ss.ss << '\n';
    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 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Incorrect 2 ms 256 KB Output isn't correct
7 Incorrect 7 ms 504 KB Output isn't correct
8 Correct 7 ms 504 KB Output is correct
9 Incorrect 8 ms 504 KB Output isn't correct
10 Incorrect 8 ms 504 KB Output isn't correct
11 Incorrect 9 ms 504 KB Output isn't correct
12 Incorrect 9 ms 632 KB Output isn't correct
13 Incorrect 45 ms 1268 KB Output isn't correct
14 Incorrect 108 ms 3664 KB Output isn't correct
15 Incorrect 228 ms 6928 KB Output isn't correct
16 Incorrect 258 ms 7204 KB Output isn't correct
17 Incorrect 319 ms 8184 KB Output isn't correct
18 Incorrect 350 ms 8536 KB Output isn't correct
19 Incorrect 393 ms 8928 KB Output isn't correct
20 Incorrect 457 ms 9908 KB Output isn't correct