Submission #770373

#TimeUsernameProblemLanguageResultExecution timeMemory
770373Trisanu_DasLet's Win the Election (JOI22_ho_t3)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define b first #define a second int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; pair<int, int> st[n]; for(int i = 0; i < n; i++){ cin >> st[i].a >> st[i].b; if(st[i].b == -1) st[i].b = 1'000'000'000; } sort(st, st + n); double ans = DBL_MAX; for(int x = 0; x < k; x++){ double dp[n + 1][k - x + 1]; memset(dp, DBL_MAX, sizeof(dp)); dp[0][0] = 0; for (int i = 0; i < n; i++) for (int j = 0; j < k - x + 1; j++) { if (j < k - x) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + (double) st[i].a / (g + 1)); dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (i - j < g ? (double) st[i].b / (i - j + 1) : .0)); } ans = min(ans, dp[n][k - x]); } cout << fixed << setprecision(9) << ans << '\n'; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:17:45: warning: overflow in conversion from 'double' to 'int' changes value from '1.7976931348623157e+308' to '2147483647' [-Woverflow]
   17 |     double dp[n + 1][k - x + 1]; memset(dp, DBL_MAX, sizeof(dp));
      |                                             ^~~~~~~
Main.cpp:21:92: error: 'g' was not declared in this scope
   21 |     if (j < k - x) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + (double) st[i].a / (g + 1));
      |                                                                                            ^
Main.cpp:22:58: error: 'g' was not declared in this scope
   22 |     dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (i - j < g ? (double) st[i].b / (i - j + 1) : .0));
      |                                                          ^