Submission #123224

# Submission time Handle Problem Language Result Execution time Memory
123224 2019-06-30T13:49:33 Z cvele Kisik (COCI19_kisik) C++14
0 / 90
9 ms 5308 KB
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 100005;

int n, k;
vector <int> mat[N];
multiset <int> ms;

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int w, h;
    cin >> w >> h;
    mat[h].push_back(w);
  }
  long long ans = 2e18, sum = 0;
  for (int i = 1; i < N; i++) {
    for (auto it : mat[i]) {
      ms.insert(it);
      sum += it;
    }
    while (ms.size() > k) {
      sum -= *ms.rbegin();
      ms.erase(--ms.end());
    }
    if (ms.size() == k) {
      ans = min(ans, sum * i);
    }
  }
  cout << ans << endl;
  return 0;
}

Compilation message

kisik.cpp: In function 'int main()':
kisik.cpp:41:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (ms.size() > k) {
            ~~~~~~~~~~^~~
kisik.cpp:45:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (ms.size() == k) {
         ~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 5112 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 5104 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 5308 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 5112 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 5112 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 5112 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 5240 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 5112 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 5212 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -