답안 #200571

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
200571 2020-02-07T11:40:17 Z Asrapogorgon Kisik (COCI19_kisik) C++14
90 / 90
1445 ms 60480 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(){
  ios::sync_with_stdio(0);
  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:28:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       while(ms.size()>k) {
             ~~~~~~~~~^~
kisik.cpp:34:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(ms.size()==k) {
        ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 380 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 9 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 9 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 7 ms 376 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 8 ms 376 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 9 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 128 ms 8672 KB Output is correct
2 Correct 685 ms 25048 KB Output is correct
3 Correct 804 ms 37568 KB Output is correct
4 Correct 723 ms 34884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 325 ms 13372 KB Output is correct
2 Correct 58 ms 5096 KB Output is correct
3 Correct 136 ms 9696 KB Output is correct
4 Correct 604 ms 30548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 250 ms 13784 KB Output is correct
2 Correct 261 ms 16852 KB Output is correct
3 Correct 220 ms 9684 KB Output is correct
4 Correct 1445 ms 60480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 272 ms 13268 KB Output is correct
2 Correct 1114 ms 37668 KB Output is correct
3 Correct 278 ms 13528 KB Output is correct
4 Correct 939 ms 42688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 433 ms 16860 KB Output is correct
2 Correct 791 ms 32276 KB Output is correct
3 Correct 528 ms 22612 KB Output is correct
4 Correct 365 ms 20436 KB Output is correct