U E D R , A S I H C RSS

1R/2016_09_24 (rev. 1.3)

1R/2016_09_24



1. 오늘의 문제

2. 참가자


3. 코드

3.1. 15이원준

#include<iostream>
#include<algorithm>
#include<set>
#include<utility>
#include<queue>

using namespace std;

class PairCompare
{
public:
  bool operator()(pair<int,int> &p1, pair<int,int> &p2){
     if(p1.first == p2.first){
        return p1.second < p2.second;
     }
     else{
       return p1.first < p2.first;
     }
   }
};


int main(){
  priority_queue<pair<int, int>, vector<pair<int, int>>, PairCompare> que;
  multiset<int> bag;
  int N, K;
  long long int ans = 0;
  cin >> N >> K;
  for(int i = 0; i<N; i++){
    int tmp1, tmp2;
    scanf("%d %d", &tmp1, &tmp2);
    que.push(make_pair(tmp2, tmp1));
  }
  for(int i = 0; i<K; i++){
    int tmp;
    scanf("%d", &tmp);
    bag.insert(tmp);
  }
  while(que.size() && bag.size()){
    pair<int,int> tmp = que.top();
    que.pop();
    auto p = bag.lower_bound(tmp.second);
    if(p != bag.end()){
      ans+= tmp.first;
      bag.erase(p);
    }
  }
  cout<< ans<<endl;
}

3.2. 박인서


3.3. 곽정흠


4. 아이디어

4.1. 15이원준


4.2. 박인서


4.3. 곽정흠

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:07
Processing time 0.0205 sec