Submission #530532

# Submission time Handle Problem Language Result Execution time Memory
530532 2022-02-25T18:21:18 Z peuch Hotel (CEOI11_hot) C++17
0 / 100
442 ms 14560 KB
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 5e5 + 10;

int n, m, o;
pair<int, int> v[MAXN];
pair<int, int> p[MAXN];
vector<long long> moedas;

int main(){
  scanf("%d %d %d", &n, &m, &o);
  for(int i = 1; i <= n; i++)
    scanf("%d %d", &v[i].second, &v[i].first);
  for(int i = 1; i <= m; i++)
    scanf("%d %d", &p[i].second, &p[i].first);
  sort(v + 1, v + 1 + n);
  sort(p + 1, p + 1 + m);
  int id = 1;
  multiset<int> s;
  for(int i = 1; i <= n; i++){
    while(id <= m && p[id].first <= v[i].first){
      s.insert(p[id].second);
      id++;
    }
    if(!s.empty()){
      moedas.push_back((*s.begin()) + v[i].second);
      s.erase(s.begin());
    }
  }
  long long ans = 0;
  long long sum = 0;
  sort(moedas.begin(), moedas.end());
  for(int i = 0; i < min(o, (int) moedas.size()); i++){
    sum -= moedas[i];
    ans = max(ans, sum);
  }
  printf("%lld\n", ans);
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d %d %d", &n, &m, &o);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
hot.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d %d", &v[i].second, &v[i].first);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hot.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d %d", &p[i].second, &p[i].first);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 1604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 161 ms 5708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 347 ms 11280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 442 ms 14560 KB Output isn't correct
2 Halted 0 ms 0 KB -