답안 #200568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
200568 2020-02-07T11:38:12 Z Asrapogorgon Kisik (COCI19_kisik) C++14
80 / 90
2000 ms 73252 KB
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define int long long 
const int maxn=1e6+7;
/*Almost copy pasted part :)*/
using namespace std;
int n,k;
vector<pair<int, int>>vec;
multiset<int>ms;
int32_t 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=1e18+7,sum=0;
  for (int i=1;i<maxn;i++){
    while(pos<n&&vec[pos].first<=i) {
      sum+=vec[pos].second;
      ms.insert(vec[pos].second);
      while(ms.size()>k) {
        sum-=*ms.rbegin();
        ms.erase(--ms.end());
      }
      pos++;
    }
    if(ms.size()==k) {
      ans=min(ans,sum*i);
    }
  }
  cout<<ans<<endl;
}

Compilation message

kisik.cpp: In function 'int32_t main()':
kisik.cpp:27:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       while(ms.size()>k) {
             ~~~~~~~~~^~
kisik.cpp:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(ms.size()==k) {
        ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 9 ms 392 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 376 KB Output is correct
2 Correct 10 ms 376 KB Output is correct
3 Correct 8 ms 380 KB Output is correct
4 Correct 8 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 9 ms 376 KB Output is correct
4 Correct 9 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 376 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 9 ms 376 KB Output is correct
4 Correct 11 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 333 ms 8796 KB Output is correct
2 Correct 1192 ms 33256 KB Output is correct
3 Correct 1382 ms 45584 KB Output is correct
4 Correct 1162 ms 42288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 655 ms 13488 KB Output is correct
2 Correct 114 ms 6248 KB Output is correct
3 Correct 249 ms 11716 KB Output is correct
4 Correct 989 ms 36920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 428 ms 13804 KB Output is correct
2 Correct 644 ms 24220 KB Output is correct
3 Correct 529 ms 15024 KB Output is correct
4 Execution timed out 2062 ms 73252 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 493 ms 13392 KB Output is correct
2 Correct 1713 ms 49232 KB Output is correct
3 Correct 501 ms 17368 KB Output is correct
4 Correct 1435 ms 51832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 875 ms 17100 KB Output is correct
2 Correct 1161 ms 40508 KB Output is correct
3 Correct 857 ms 29192 KB Output is correct
4 Correct 560 ms 24540 KB Output is correct