Submission #928237

#TimeUsernameProblemLanguageResultExecution timeMemory
928237pccLet's Win the Election (JOI22_ho_t3)C++14
10 / 100
8 ms456 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define fs first #define sc second #define ld double const ll inf = 1e12; const ll mxn = 550; pll arr[mxn]; ll N,K; bitset<mxn> done; inline ld f(ll cnt){ done.reset(); vector<pll> v; for(int i= 0;i<N;i++)v.push_back({arr[i].sc,i}); sort(v.begin(),v.end()); ld re = 0,c = 1; for(int i = 0;i<cnt;i++){ re += v[i].fs/c; c+=1; done[v[i].sc] = true; } ll now = cnt; for(int i = 0;i<N;i++){ if(now>=K)break; if(done[i])continue; re += arr[i].fs/c; now++; } return re; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>N>>K; for(int i = 0;i<N;i++)cin>>arr[i].fs>>arr[i].sc,arr[i].sc = (arr[i].sc == -1?inf:arr[i].sc); sort(arr,arr+N); ld ans = inf; for(int i = 0;i<=K;i++)ans = min(ans,f(i)); cout<<fixed<<setprecision(20)<<ans; }
#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...