Submission #598822

#TimeUsernameProblemLanguageResultExecution timeMemory
598822denniskimLet's Win the Election (JOI22_ho_t3)C++17
56 / 100
2626 ms1048576 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef __int128 lll; typedef long double ld; #define MAX 9223372036854775807LL #define MIN -9223372036854775807LL #define INF 0x3f3f3f3f3f3f3f3f #define fi first #define se second ll n; ll k; pair<ll, ll> a[510]; ld ans = INF; ll chk[510]; ld dp[510][510][510]; ld gap[510]; ll l, r; ld query(ll i) { if(gap[i]) return gap[i]; for(ll j = 0 ; j <= n ; j++) { for(ll o = 0 ; o <= k ; o++) { for(ll oo = 0 ; oo <= i ; oo++) dp[j][o][oo] = 10000000; } } dp[0][0][0] = 0; for(ll j = 1 ; j <= n ; j++) { for(ll o = 0 ; o <= k ; o++) { for(ll oo = 0 ; oo <= i ; oo++) { dp[j][o][oo] = min(dp[j][o][oo], dp[j - 1][o][oo]); if(o >= 1) dp[j][o][oo] = min(dp[j][o][oo], dp[j - 1][o - 1][oo] + (ld)a[j].se / (ld)(i + 1)); if(o >= 1 && oo >= 1) dp[j][o][oo] = min(dp[j][o][oo], dp[j - 1][o - 1][oo - 1] + (ld)a[j].fi / (ld)oo); } } } return gap[i] = dp[n][k][i]; } int main(void) { scanf("%lld", &n); scanf("%lld", &k); for(ll i = 1 ; i <= n ; i++) { scanf("%lld %lld", &a[i].se, &a[i].fi); if(a[i].fi == -1) a[i].fi = 1000000000; } sort(a + 1, a + 1 + n); l = 0, r = k; while(l + 2 < r) { ll mid1 = (l * 2 + r) / 3; ll mid2 = (l + r * 2) / 3; if(query(mid1) <= query(mid2)) r = mid2; else l = mid1; } for(ll i = l ; i <= r ; i++) ans = min(ans, query(i)); printf("%.10Lf", ans); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:60:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |  scanf("%lld", &n);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:61:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |  scanf("%lld", &k);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:65:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |   scanf("%lld %lld", &a[i].se, &a[i].fi);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...