답안 #123230

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123230 2019-06-30T13:56:26 Z cvele Kisik (COCI19_kisik) C++14
80 / 90
2000 ms 50768 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;
vector < pair <int, int> > vec;
multiset <int> ms;

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int w, h;
    cin >> w >> h;
    vec.push_back({h, w});
  }
  sort(vec.begin(), vec.end());
  int pos = 0;
  long long ans = 2e18, sum = 0;
  for (int i = 1; i < N; i++) {
    while (pos < vec.size() && vec[pos].first <= i) {
      sum += vec[pos].second;
      ms.insert(vec[pos].second);
      pos++;
    }
    while (ms.size() > k) {
      sum -= *ms.rbegin();
      ms.erase(--ms.end());
    }
    if (ms.size() == k) {
      ans = min(ans, 1ll * sum * i);
    }
  }
  cout << ans << endl;
  return 0;
}

Compilation message

kisik.cpp: In function 'int main()':
kisik.cpp:39:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (pos < vec.size() && vec[pos].first <= i) {
            ~~~~^~~~~~~~~~~~
kisik.cpp:44:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (ms.size() > k) {
            ~~~~~~~~~~^~~
kisik.cpp:48:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (ms.size() == k) {
         ~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 6 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 5 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 6 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 6 ms 504 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 384 ms 5052 KB Output is correct
2 Correct 1144 ms 20580 KB Output is correct
3 Correct 1289 ms 33384 KB Output is correct
4 Correct 1093 ms 31064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 703 ms 10720 KB Output is correct
2 Correct 129 ms 4840 KB Output is correct
3 Correct 263 ms 9060 KB Output is correct
4 Correct 956 ms 27228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 438 ms 12492 KB Output is correct
2 Correct 723 ms 9180 KB Output is correct
3 Correct 566 ms 7372 KB Output is correct
4 Execution timed out 2058 ms 50768 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 535 ms 11600 KB Output is correct
2 Correct 1750 ms 31064 KB Output is correct
3 Correct 483 ms 11872 KB Output is correct
4 Correct 1464 ms 37808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 994 ms 11496 KB Output is correct
2 Correct 1203 ms 28144 KB Output is correct
3 Correct 968 ms 19380 KB Output is correct
4 Correct 612 ms 18212 KB Output is correct