Submission #676635

#TimeUsernameProblemLanguageResultExecution timeMemory
676635owoovoLet's Win the Election (JOI22_ho_t3)C++14
10 / 100
4 ms340 KiB
#include<bits/stdc++.h> #define ld double #define ll long long using namespace std; multiset<pair<int,int>> a,b,c; ld ans=1000000; int main(){ ll n,k,kk; cin>>n>>k; for(ll i=0;i<n;i++){ int x,y; cin>>x>>y; a.insert(make_pair(x,y)); if(y!=-1){ b.insert(make_pair(y,x)); kk++; } } for(ll i=0;;i++){ ld nowans=0; ld nowc=1; for(auto r:c){ nowans+=ld(r.first)/nowc; nowc++; } multiset<pair<int,int>>::iterator s=a.begin(); for(int j=i+1;j<=k;j++){ pair<int,int> u=*s; nowans+=ld(u.first)/nowc; if(u.first==u.second)nowc++; s++; } ans=min(ans,nowans); if(b.size()==0){ break; }else{ c.insert(*b.begin()); a.erase(a.find(make_pair((*b.begin()).second,(*b.begin()).first))); b.erase(b.begin()); } } cout<<ans<<"\n"; return 0; }
#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...