Submission #1319573

#TimeUsernameProblemLanguageResultExecution timeMemory
1319573Sir_Ahmed_ImranLet's Win the Election (JOI22_ho_t3)C++17
10 / 100
1 ms332 KiB
// 01001100 01001111 01010100 01000001 \\ // \\ // ╦ ╔═╗╔╦╗╔═╗ \\ // ║ ║ ║ ║ ╠═╣ \\ // ╩═╝╚═╝ ╩ ╩ ╩ \\ // \\ // 01001100 01001111 01010100 01000001 \\ #include <bits/stdc++.h> using namespace std; #define nl '\n' #define ff first #define ss second #define ll long long #define ld long double #define terminator main #define pll pair<ll,ll> #define add insert #define append push_back #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) const int N = 512; int n, k; bool vis[N]; double a[N]; double b[N]; vector<pair<double, int>> v, u; double get(int x){ double ans = 0; double p = 1; for(int i = 0; i < x; i++){ ans += u[i].ff / p; vis[u[i].ss] = 1; p++; } int cnt = x; for(int i = 0; cnt < k; i++){ if(vis[v[i].ss]) continue; ans += v[i].ff / p; cnt++; } for(int i = 0; i < n; i++) vis[i] = 0; return ans; } void solve(){ cin >> n >> k; cout << fixed << setprecision(15); for(int i = 0; i < n; i++){ cin >> a[i] >> b[i]; v.append({a[i], i}); if(b[i] >= a[i]) u.append({b[i], i}); } sort(all(v)); sort(all(u)); double ans = 1e18; for(int i = 0; i <= min(k, int(u.size())); i++) ans = min(ans, get(i)); cout << ans; } int terminator(){ L0TA; int T = 1; //cin >> T; while(T--) solve(); 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...