답안 #167005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167005 2019-12-05T07:51:18 Z itgl 학교 설립 (IZhO13_school) C++14
15 / 100
2000 ms 12356 KB
#include<bits/stdc++.h>
#define ss second
#define pb push_back
#define mp make_pair
#define ff first

using namespace std;

int n,m,s;
priority_queue<pair<int,int> > pq,pq1;
int main(){
  cin >> n >> m >> s;

  for(int i=1;i<=n;i++){
    int x,y;
    cin >> x >> y;
    pq.push(mp(x,x-y));
  }
  int res=0;
  while(!pq.empty()){
    if(m>0){
      if(pq.top().ss>0&&s<=0){
        res+=pq.top().ff;

        pq.pop();
        m--;
      }else if(s>0){
        pq1.push(mp(pq.top().ff-pq.top().ss,-pq.top().ss));
        pq.pop();
      }

    }
    else{
      pq1.push(mp(pq.top().ff-pq.top().ss,-pq.top().ss));
      pq.pop();
    }
  }
  while(!pq1.empty()){
    if(s>0){
      res+=pq1.top().ff;
      pq1.pop();
      s--;
    }
    else {
      pq.push(mp(pq1.top().ff-pq1.top().ss,-pq.top().ss));
      pq1.pop();
    }
  }
  while(m--){
    res+=pq.top().ff;
    pq.pop();
  }


  cout << res;

  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Execution timed out 2043 ms 256 KB Time limit exceeded
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Incorrect 2 ms 256 KB Output isn't correct
7 Incorrect 8 ms 504 KB Output isn't correct
8 Incorrect 8 ms 508 KB Output isn't correct
9 Incorrect 9 ms 504 KB Output isn't correct
10 Incorrect 9 ms 504 KB Output isn't correct
11 Incorrect 9 ms 500 KB Output isn't correct
12 Incorrect 9 ms 504 KB Output isn't correct
13 Incorrect 55 ms 1776 KB Output isn't correct
14 Incorrect 111 ms 3280 KB Output isn't correct
15 Correct 231 ms 6500 KB Output is correct
16 Incorrect 258 ms 6756 KB Output isn't correct
17 Incorrect 353 ms 7612 KB Output isn't correct
18 Incorrect 381 ms 8148 KB Output isn't correct
19 Incorrect 429 ms 8420 KB Output isn't correct
20 Incorrect 458 ms 12356 KB Output isn't correct