Submission #923827

#TimeUsernameProblemLanguageResultExecution timeMemory
923827OAleksaLet's Win the Election (JOI22_ho_t3)C++14
0 / 100
1518 ms596 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define int long long const int N = 550; const int inf = 1e18; int n, k; pair<int, int> a[N]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt = 1; //cin >> tt; while (tt--) { cin >> n >> k; for (int i = 0;i < n;i++) { cin >> a[i].f >> a[i].s; if (a[i].s == -1) a[i].s = inf; } double ans = inf; for (int mask = 1;mask < (1 << n);mask++) { vector<pair<int, int>> gas; vector<int> tm; for (int i = 0;i < n;i++) { if (mask & (1 << i)) { gas.push_back(a[i]); tm.push_back(a[i].f); } } int m = gas.size(); if (m != k) continue; sort(gas.begin(), gas.end(), [&](pair<int, int> x, pair<int, int> y) { if (x.s == y.s) return x.f > y.f; return x.s < y.s; }); sort(tm.begin(), tm.end()); double z = 0; for (int i = 0;i < k;i++) z += tm[i]; double t = 0; for (int i = 1;i < k;i++) { t += (double)gas[i - 1].s / i; vector<int> x; for (int j = i;j < m;j++) x.push_back(gas[j].f); sort(x.begin(), x.end()); double res = t; for (int j = 0;j < k - i;j++) res += (double)x[j] / (i + 1); z = min(z, res); } ans = min(ans, z); } cout << fixed << setprecision(15) << ans; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:43:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   43 |     for (int i = 0;i < k;i++)
      |     ^~~
Main.cpp:45:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   45 |    double t = 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...