Submission #638717

#TimeUsernameProblemLanguageResultExecution timeMemory
638717jamezzzLet's Win the Election (JOI22_ho_t3)C++17
10 / 100
10 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define sf scanf #define pf printf typedef long long ll; typedef long double ld; typedef pair<int,int> ii; #define maxn 505 #define INF 1023456789 int n,k,a[maxn],b[maxn]; bool have[maxn]; vector<ii> v; ld memo[maxn][maxn]; int main(){ sf("%d%d",&n,&k); for(int i=0;i<n;++i){ int x,y; sf("%d%d",&x,&y); if(y==-1)y=INF; v.push_back({x,y}); } sort(v.begin(),v.end(),[](ii &a,ii &b){ if(a.se==b.se)return a.fi>b.fi; else return a.se<b.se; }); int num=0; for(int i=0;i<n;++i){ tie(a[i],b[i])=v[i]; if(b[i]!=INF)++num; } ld ans=INF; for(int ppl=0;ppl<=num;++ppl){ ld cur=0; for(int i=0;i<ppl;++i){ cur+=((ld)b[i])/((ld)i+1); } priority_queue<int,vector<int>,greater<int>> pq; for(int i=ppl;i<n;++i)pq.push(a[i]); for(int i=0;i<k-ppl;++i){ cur+=((ld)pq.top())/((ld)ppl+1); pq.pop(); } ans=min(ans,cur); } pf("%Lf\n",ans); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:21:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  sf("%d%d",&n,&k);
      |    ^
Main.cpp:24:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   sf("%d%d",&x,&y);
      |     ^
#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...