Submission #1088822

#TimeUsernameProblemLanguageResultExecution timeMemory
1088822peacebringer1667Let's Win the Election (JOI22_ho_t3)C++17
10 / 100
10 ms600 KiB
#include<bits/stdc++.h> #define ll long long #define ldb long double #define fi first #define se second #define sza(a) (int)a.size() #define pir pair<int,int> #define pirll pair<ll,ll> using namespace std; const int maxn = 5e2 + 5; const ll inf = 1e17; void minimize(ldb &x,ldb y){ x = min(x,y); } pair <ldb,ldb> a[maxn]; bool cmp(pair <ldb,ldb> x,pair <ldb,ldb> y){ return (x.se < y.se); } void input(int n){ for (int i = 1 ; i <= n ; i++){ cin >> a[i].fi >> a[i].se; if (a[i].se == -1) a[i].se = inf; } sort(a + 1,a + 1 + n,cmp); } ldb solve(int n,int k,int collab){ ldb res = 0; int cnt = 1; for (int i = 1 ; i <= collab ; i++){ if (a[i].se == inf) return inf; res += a[i].se/(ldb)cnt; cnt++; } if (collab == k) return res; vector <ldb> lst; for (int i = collab + 1 ; i <= n ; i++) lst.push_back(a[i].fi); sort(lst.begin(),lst.end()); for (int i = 0 ; i < k - collab ; i++) res += lst[i]/(ldb)cnt; return res; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); // freopen("ELECTION.inp","r",stdin); // freopen("ELECTION.out","w",stdout); int n,k; cin >> n >> k; input(n); ldb res = inf; for (int collab = 0 ; collab <= k ; collab++) res = min(res,solve(n,k,collab)); cout << fixed << setprecision(10) << res; 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...