Submission #229494

# Submission time Handle Problem Language Result Execution time Memory
229494 2020-05-04T19:26:45 Z anayk Hotel (CEOI11_hot) C++14
10 / 100
1581 ms 55572 KB
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

#define int long long

signed main()
{
  int n, m, o;
  std::cin >> n >> m >> o;

  std::vector<std::pair<int, int> > rooms(n);
  for(int i = 0; i < n; i++) {
    std::cin >> rooms[i].second >> rooms[i].first;
  }

  std::vector<std::pair<int, int> > cust(m);
  for(int i = 0; i < m; i++) {
    std::cin >> cust[i].second >> cust[i].first;
  }

  std::sort(cust.begin(), cust.end());
  std::sort(rooms.begin(), rooms.end());

  std::multiset<int> avail;
  std::multiset<int> cand;
  
  int j = 0;
  for(int i = 0; i < n; i++) {
    while(j < m && cust[j].first <= rooms[i].first) {
      avail.insert(-cust[j].second);
      j++;
    }

    if(!avail.empty()) {
      cand.insert((*avail.begin()) + rooms[i].second);
      avail.erase(avail.begin());
    }
  }

  int ans = 0;
  while(!cand.empty() && o > 0) {
    if(*cand.begin() >= 0)
      break;
    ans -= *cand.begin();
    cand.erase(cand.begin());
  }

  std::cout << ans << std::endl;

  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 256 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 1192 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 129 ms 4984 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 224 ms 8480 KB Output is correct
2 Incorrect 145 ms 5624 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 641 ms 23672 KB Output is correct
2 Incorrect 394 ms 17528 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1372 ms 47072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1581 ms 55572 KB Output isn't correct
2 Halted 0 ms 0 KB -