Submission #806912

#TimeUsernameProblemLanguageResultExecution timeMemory
806912CookieLet's Win the Election (JOI22_ho_t3)C++14
100 / 100
416 ms3940 KiB
#include<bits/stdc++.h> #include<fstream> #pragma GCC optimize("Ofast,O3,unroll-loops") #pragma GCC target("avx2") using namespace std; //ifstream fin("FEEDING.INP"); //ofstream fout("FEEDING.OUT"); #define sz(a) (int)a.size() #define ll long long #define pb push_back #define forr(i, a, b) for(int i = a; i < b; i++) #define dorr(i, a, b) for(int i = a; i >= b; i--) #define ld long double #define vt vector #include<fstream> #define fi first #define se second #define pll pair<ll, ll> #define pii pair<int, int> const int base = 74; const ll mod = 1e9 + 7, inf = 1e18, mxv = 1005, mxn = 2e5 + 5; int n, k; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ld dp[505][505]; pll p[mxn + 1]; bool cmp(pll &a, pll &b){ return(a.se < b.se); } ld get(int x){ for(int i = 1; i <= n; i++){ for(int j = 0; j <= min(i, x); j++){ dp[i][j] = inf; int other = i - j; if(other <= k - x){ dp[i][j] = dp[i - 1][j] + (ld)p[i].se / (other); }else{ dp[i][j] = dp[i - 1][j]; } other = min(other, k - x); if(j > 0){ dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (ld)p[i].fi / (k - x + 1)); } } } return(dp[n][x]); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; int cant = 0; for(int i = 1; i <= n; i++){ cin >> p[i].fi >> p[i].se; if(p[i].se == -1){ p[i].se = 1e9; cant++; } } sort(p + 1, p + n + 1, cmp); int l = max(k - n + cant, 0), r = k; ld ans = inf; for(int i = 0; i <= k; i++)ans = min(ans, get(i)); cout << fixed << setprecision(20) << ans; return(0); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:61:9: warning: unused variable 'l' [-Wunused-variable]
   61 |     int l = max(k - n + cant, 0), r = k;
      |         ^
Main.cpp:61:35: warning: unused variable 'r' [-Wunused-variable]
   61 |     int l = max(k - n + cant, 0), r = k;
      |                                   ^
#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...