Submission #123225

# Submission time Handle Problem Language Result Execution time Memory
123225 2019-06-30T13:51:26 Z cvele Kisik (COCI19_kisik) C++14
50 / 90
2000 ms 119800 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 = 1000005;

int n, k;
map < int, vector <int> > mat;
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 Correct 303 ms 78712 KB Output is correct
2 Correct 301 ms 78584 KB Output is correct
3 Correct 334 ms 78840 KB Output is correct
4 Correct 288 ms 78724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 282 ms 78584 KB Output is correct
2 Correct 279 ms 78712 KB Output is correct
3 Correct 277 ms 78712 KB Output is correct
4 Correct 387 ms 78604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 302 ms 78776 KB Output is correct
2 Correct 333 ms 78588 KB Output is correct
3 Correct 281 ms 78840 KB Output is correct
4 Correct 328 ms 78580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 298 ms 78740 KB Output is correct
2 Correct 277 ms 78700 KB Output is correct
3 Correct 308 ms 78584 KB Output is correct
4 Correct 275 ms 78584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 960 ms 90612 KB Output is correct
2 Execution timed out 2058 ms 107872 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1570 ms 101504 KB Output is correct
2 Correct 517 ms 85624 KB Output is correct
3 Correct 820 ms 92280 KB Output is correct
4 Correct 1999 ms 119800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1107 ms 98324 KB Output is correct
2 Correct 1629 ms 99624 KB Output is correct
3 Correct 1337 ms 97200 KB Output is correct
4 Execution timed out 2065 ms 75708 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 1286 ms 99288 KB Output is correct
2 Execution timed out 2082 ms 84852 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2080 ms 108152 KB Time limit exceeded
2 Halted 0 ms 0 KB -