Submission #200568

#TimeUsernameProblemLanguageResultExecution timeMemory
200568AsrapogorgonKisik (COCI19_kisik)C++14
80 / 90
2062 ms73252 KiB
#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 (stderr)

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) {
        ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...