Submission #704219

#TimeUsernameProblemLanguageResultExecution timeMemory
704219ld_minh4354Let's Win the Election (JOI22_ho_t3)C++17
10 / 100
1 ms328 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pb push_back #define debug(x) cout<<#x<<": "<<x<<"\n" signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // freopen("input.000","r",stdin); // freopen("output.000","w",stdout); // srand((unsigned)time(NULL)); // rand() int n,a[505],b[505],size_a,size_b,i,k,x,y; long double sum,ans; cin>>n>>k;size_a=size_b=0; for (i=1;i<n+1;i++) { cin>>x>>y; if (y!=-1) { size_a++; a[size_a]=x; } else { size_b++; b[size_b]=x; } } sort(a+1,a+size_a+1); sort(b+1,b+size_b+1); ans=1e9; for (x=0;x<=k;x++) if (x<=size_a and k-x<=size_b) { sum=0; for (i=1;i<x+1;i++) sum+=(double)a[i]/i; for (i=1;i<=k-x;i++) sum+=(double)b[i]/(x+1); ans=min(ans,sum); } cout<<fixed<<setprecision(4)<<ans<<"\n"; }
#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...