Submission #148608

#TimeUsernameProblemLanguageResultExecution timeMemory
148608CHT를 사랑하는 모임 (#200)Crosses on the Grid (FXCUP4_cross)C++17
100 / 100
134 ms8860 KiB
#include "cross.h" #include <bits/stdc++.h> #define fi first #define se second using namespace std; typedef long long ll; typedef long double db; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<db,db> pdb; typedef tuple<int,int,int,int> TP; typedef vector<vector<ll>> mat; const int N=2e5+5; const ll mod=1e9+7; int n,k; ll ans; pll p[N]; priority_queue<ll,vector<ll>,greater<ll>> pq; long long SelectCross(int K, std::vector<int> I, std::vector<int> O) { n=I.size(); k=K; for(int i=1;i<=n;i++){ p[i]=pll(I[i-1],O[i-1]); } sort(p+1,p+1+n); for(int i=n;i>=1;i--){ if(pq.size()==k-1){ ll v; if(k!=1) v=min(pq.top(),p[i].se); else v=p[i].se; ans=max(ans,p[i].fi*(2LL*v-p[i].fi)); //cout<<p[i].fi<<" : "<<pq.top()<<" "<<" "<<v<<ans<<endl; } pq.push(p[i].se); if(pq.size()==k) pq.pop(); } return ans; }

Compilation message (stderr)

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:26:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(pq.size()==k-1){
      ~~~~~~~~~^~~~~
cross.cpp:34:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(pq.size()==k) pq.pop();
      ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...