Submission #886982

#TimeUsernameProblemLanguageResultExecution timeMemory
886982dubabubaLet's Win the Election (JOI22_ho_t3)C++14
23 / 100
2567 ms760 KiB
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 10; const int mxn = 20; int a[mxn], n; int b[mxn], k; vector<int> good; vector<int> badd; double ans = 1e9; void solve(int map) { vector<int> vote = badd; vector<int> help; double ret = 0.0; for(int i = 0; i < good.size(); i++) if(map & (1 << i)) help.push_back(good[i]); else vote.push_back(good[i]); if(help.size() > k) return; sort(help.begin(), help.end(), [&](int i, int j) { return b[i] < b[j]; }); sort(vote.begin(), vote.end(), [&](int i, int j) { return a[i] < a[j]; }); int helpers = 0; for(int i : help) { ret += 1.0 * b[i] / (1.0 + helpers); helpers++; } for(int j = 0; j < (k - help.size()); j++) { int i = vote[j]; ret += 1.0 * a[i] / (1.0 + helpers); } ans = min(ans, ret); } int main() { cin >> n >> k; for(int i = 0; i < n; i++) { cin >> a[i] >> b[i]; if(b[i] == -1) { b[i] = inf; badd.push_back(i); } else good.push_back(i); } for(int bit = 0; bit < (1 << good.size()); bit++) solve(bit); cout << setprecision(5) << fixed << ans << '\n'; return 0; }

Compilation message (stderr)

Main.cpp: In function 'void solve(int)':
Main.cpp:18:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i = 0; i < good.size(); i++)
      |                 ~~^~~~~~~~~~~~~
Main.cpp:24:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |  if(help.size() > k) return;
      |     ~~~~~~~~~~~~^~~
Main.cpp:35:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for(int j = 0; j < (k - help.size()); j++) {
      |                 ~~^~~~~~~~~~~~~~~~~~~
#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...