Submission #538671

#TimeUsernameProblemLanguageResultExecution timeMemory
538671BenmathLet's Win the Election (JOI22_ho_t3)C++14
10 / 100
6 ms304 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n,k; cin>>n>>k; double a[n],b[n]; vector<pair<double,double>>v; for(int i=0;i<n;i++){ cin>>a[i]>>b[i]; if(b[i]==-1){ b[i]=1e18; } v.push_back({b[i],a[i]}); } sort(v.begin(),v.end()); double sum=0; double mini=1e18; int t1=0; for(int i=0;i<k;i++){ //cout<<mini<<endl; double res=sum; vector<double>v1; for(int j=i;j<n;j++){ v1.push_back(v[j].second); } sort(v1.begin(),v1.end()); int ro=(k-i); double i1=i+1; for(int j=0;j<ro;j++){ res=res+v1[j]/i1; } if(res<mini){ mini=res; } if(v[i].first==1e18){ t1++; break; } sum=sum+v[i].first/i1; } if(sum<mini and t1==0){ mini=sum; } cout<<mini<<endl; }
#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...