Submission #529438

#TimeUsernameProblemLanguageResultExecution timeMemory
529438wiwihoLet's Win the Election (JOI22_ho_t3)C++14
10 / 100
18 ms332 KiB
#include <bits/stdc++.h> #define iter(a) a.begin(), a.end() #define mp make_pair #define F first #define S second #define eb emplace_back #define lsort(a) sort(iter(a)) #define gsort(a) sort(iter(a), greater<>()) using namespace std; typedef long long ll; typedef long double ld; using pii = pair<int, int>; ll iceil(ll a, ll b){ return (a + b - 1) / b; } int n, k; vector<int> a, b; ld calc(int cnt){ vector<pii> tmp; for(int i = 1; i <= n; i++){ if(b[i] == -1) continue; tmp.eb(mp(b[i], i)); } if(tmp.size() < cnt) return 1e87; lsort(tmp); vector<bool> use(n + 1); ld ans = 0; for(int i = 0; i < cnt; i++){ use[tmp[i].S] = true; ans += (ld)tmp[i].F / (i + 1); } tmp.clear(); for(int i = 1; i <= n; i++){ if(use[i]) continue; tmp.eb(mp(a[i], i)); } lsort(tmp); for(int i = 0; i < k - cnt; i++){ ans += (ld)tmp[i].F / (cnt + 1); } return ans; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; a.resize(n + 1); b.resize(n + 1); for(int i = 1; i <= n; i++) cin >> a[i] >> b[i]; ld ans = 1e87; for(int i = 0; i <= k; i++) ans = min(ans, calc(i)); cout << fixed << setprecision(20) << ans << "\n"; return 0; }

Compilation message (stderr)

Main.cpp: In function 'ld calc(int)':
Main.cpp:32:19: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |     if(tmp.size() < cnt) return 1e87;
      |        ~~~~~~~~~~~^~~~~
#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...