Submission #100976

#TimeUsernameProblemLanguageResultExecution timeMemory
100976KLPPKisik (COCI19_kisik)C++14
90 / 90
501 ms32360 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int lld; int main(){ int n,k; scanf("%d %d",&n,&k); pair<lld,lld> arr[n]; for(int i=0;i<n;i++){ scanf("%lld %lld",&arr[i].second,&arr[i].first); } sort(arr,arr+n); priority_queue<int> pq; lld sum=0; lld ans=1000000000000000000; for(int i=0;i<n;i++){ pq.push(arr[i].second); sum+=arr[i].second; if(pq.size()>k){ sum-=pq.top(); pq.pop(); } if(pq.size()==k){ ans=min(ans,sum*arr[i].first); } }cout<<ans<<endl; return 0; }

Compilation message (stderr)

kisik.cpp: In function 'int main()':
kisik.cpp:20:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(pq.size()>k){
        ~~~~~~~~~^~
kisik.cpp:24:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(pq.size()==k){
        ~~~~~~~~~^~~
kisik.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&n,&k);
   ~~~~~^~~~~~~~~~~~~~~
kisik.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld",&arr[i].second,&arr[i].first);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...