Submission #848331

#TimeUsernameProblemLanguageResultExecution timeMemory
848331SUNWOOOOOOOOLet's Win the Election (JOI22_ho_t3)C++17
11 / 100
115 ms2592 KiB
#include <bits/stdc++.h> using namespace std; const int mxN = 505; array <int, 2> A[mxN]; // {B, A} double dp[mxN][mxN]; // current state, no of selected collabs int n, k; void dpinit() { for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) dp[i][j] = 2e9; } int main() { scanf("%d %d", &n, &k); for (int i = 1; i <= n; i++) scanf("%d %d", &A[i][1], &A[i][0]); sort(A + 1, A + n + 1); // n == k double ans = 2e9; for (int x = 0; x <= n; x++){ // number of collabs dpinit(); dp[0][0] = 0; for (int i = 1; i <= n; i++){ for (int j = 0; j <= min(i, x); j++){ double val = 2e9; if (j) val = min(val, dp[i - 1][j - 1] + 1.0 * A[i][0] / j); val = min(val, dp[i - 1][j] + 1.0 * A[i][1] / (x + 1)); dp[i][j] = val; } } ans = min(ans, dp[n][x]); } printf("%lf\n", ans); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:16:39: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     for (int i = 1; i <= n; i++) scanf("%d %d", &A[i][1], &A[i][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...