Submission #121351

#TimeUsernameProblemLanguageResultExecution timeMemory
121351OptxPrimeKisik (COCI19_kisik)C++11
90 / 90
843 ms53068 KiB
#include <iostream> #include <cmath> #include<vector> #include <algorithm> #include <utility> #include<stack> #include<queue> using namespace std; #define pb push_back #define mp make_pair #define ll long long int main() { long long n,k,u,v; vector<pair<long long, long long>> vec; // priority_queue<pair<long long,long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>>pq; //priority_queue<pair<long long,long long>, greater<pair<long long, long long>>, vector<pair<long long, long long>>>pq; priority_queue<pair<ll,ll>> pq; cin>>n>>k; for(int i=0;i<n;i++){ cin>>u>>v; vec.pb( mp( v,u ) ); } sort( vec.begin(), vec.end() ); // cout<<endl; // for( int i=0;i<vec.size();i++ )cout<<vec[i].first << " " << vec[i].second << " et "<<endl; long long ans=1000000000000000000,w=0,h; for( int i=0;i<vec.size();i++ ){ if( pq.size() < k ){ pq.push( mp(vec[i].second, vec[i].first )); w+=vec[i].second; h=vec[i].first; if( pq.size() == k ) ans=min( ans,w*h ); //cout << pq.top().first << " " << pq.top().second << " kontas " <<endl; } else{ pair<ll,ll> maxx=pq.top(); // cout << maxx.first << " " << maxx.second <<endl; w+= vec[i].second - maxx.first; h=vec[i].first; pq.pop(); pq.push( mp( vec[i].second, vec[i].first ) ); ans=min( ans, h*w ); } } cout<<ans<<endl; return 0; }

Compilation message (stderr)

kisik.cpp: In function 'int main()':
kisik.cpp:37:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for( int i=0;i<vec.size();i++ ){
                  ~^~~~~~~~~~~
kisik.cpp:38:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if( pq.size() < k ){
             ~~~~~~~~~~^~~
kisik.cpp:42:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if( pq.size() == k ) ans=min( ans,w*h );
                 ~~~~~~~~~~^~~~
#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...