Submission #957564

#TimeUsernameProblemLanguageResultExecution timeMemory
957564PringLet's Win the Election (JOI22_ho_t3)C++17
0 / 100
2521 ms51268 KiB
#include <bits/stdc++.h> using namespace std; #ifdef MIKU string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m"; #define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x) void dout() { cout << dbrs << endl; } template <typename T, typename ...U> void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); } #else #define debug(...) 39 #endif // #define int long long #define fs first #define sc second #define mp make_pair #define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++) typedef pair<int, int> pii; const int MXN = 505; int n, k; pii p[MXN]; int suf[MXN][MXN]; double dp[MXN][MXN]; void GET_SUF() { vector<int> v; for (int i = n; i > 0; i--) { v.push_back(p[i].fs); sort(v.begin(), v.end()); suf[i][0] = 0; FOR(j, 0, v.size()) suf[i][j + 1] = suf[i][j] + v[j]; } } double calc(int g) { dp[0][0] = 0.0; FOR(j, 1, g + 1) dp[0][j] = 3.9e239; FOR(i, 1, k + 1) { dp[i][0] = dp[i - 1][0] + (double) p[i].fs / (g + 1); FOR(j, 1, g + 1) { dp[i][j] = min(dp[i - 1][j] + (double) p[i].fs / (g + 1), dp[i - 1][j - 1] + (double) p[i].sc / j); } } FOR(j, 0, g + 1) { FOR(i, 0, k + 1) cout << setw(8) << dp[i][j] << ' '; cout << endl; } cout << endl; double ans = 3.9e239; FOR(i, 0, k + 1) ans = min(ans, dp[i][g] + (double) suf[i + 1][k - i] / (g + 1)); return ans; } void miku() { cin >> n >> k; FOR(i, 1, n + 1) { cin >> p[i].fs >> p[i].sc; if (p[i].sc == -1) p[i].sc = 2e9; } sort(p + 1, p + n + 1, [](pii a, pii b) -> bool { return a.sc < b.sc; }); GET_SUF(); double ans = 3.9e239; FOR(g, 0, k + 1) { double x = calc(g); debug(g, x); ans = min(ans, x); } cout << fixed << setprecision(10) << ans << '\n'; } int32_t main() { cin.tie(0) -> sync_with_stdio(false); cin.exceptions(cin.failbit); miku(); return 0; }

Compilation message (stderr)

Main.cpp: In function 'void miku()':
Main.cpp:11:20: warning: statement has no effect [-Wunused-value]
   11 | #define debug(...) 39
      |                    ^~
Main.cpp:70:9: note: in expansion of macro 'debug'
   70 |         debug(g, x);
      |         ^~~~~
#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...