Submission #200571

#TimeUsernameProblemLanguageResultExecution timeMemory
200571AsrapogorgonKisik (COCI19_kisik)C++14
90 / 90
1445 ms60480 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(){ 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 (stderr)

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) {
        ~~~~~~~~~^~~
#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...