# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
638720 | 2022-09-07T06:58:01 Z | jamezzz | Let's Win the Election (JOI22_ho_t3) | C++17 | 478 ms | 4272 KB |
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define sf scanf #define pf printf typedef long long ll; typedef long double ld; typedef pair<int,int> ii; #define maxn 505 #define INF 1023456789 int n,k,a[maxn],b[maxn]; vector<ii> v; ld memo[maxn][maxn]; int main(){ sf("%d%d",&n,&k); for(int i=0;i<n;++i){ int x,y; sf("%d%d",&x,&y); if(y==-1)y=INF; v.push_back({x,y}); } sort(v.begin(),v.end(),[](ii &a,ii &b){ if(a.se==b.se)return a.fi>b.fi; else return a.se<b.se; }); for(int i=0;i<n;++i){ tie(a[i],b[i])=v[i]; } for(int i=0;i<=n+1;++i){ for(int j=0;j<=n+1;++j){ memo[i][j]=INF; } } memo[0][0]=0; for(int pos=0;pos<n;++pos){ for(int ppl=pos+1;ppl>=0;--ppl){ for(int vote=pos+1;vote>=0;--vote){ ld ans=memo[ppl][vote]; if(vote!=0)ans=min(ans,memo[ppl][vote-1]+(ld)a[pos]/(ppl+1)); if(vote!=0&&ppl!=0&&b[pos]<=1000){ ans=min(ans,memo[ppl-1][vote-1]+(ld)b[pos]/ppl); } if(ppl>vote&&ans!=INF)assert(false); memo[ppl][vote]=ans; } } } ld ans=INF; for(int i=0;i<=n;++i)ans=min(ans,memo[i][k]); pf("%.15Lf\n",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 328 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 277 ms | 4256 KB | Output is correct |
6 | Correct | 278 ms | 4264 KB | Output is correct |
7 | Correct | 291 ms | 4260 KB | Output is correct |
8 | Correct | 270 ms | 4260 KB | Output is correct |
9 | Correct | 310 ms | 4180 KB | Output is correct |
10 | Correct | 281 ms | 4260 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 328 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 277 ms | 4256 KB | Output is correct |
6 | Correct | 278 ms | 4264 KB | Output is correct |
7 | Correct | 291 ms | 4260 KB | Output is correct |
8 | Correct | 270 ms | 4260 KB | Output is correct |
9 | Correct | 310 ms | 4180 KB | Output is correct |
10 | Correct | 281 ms | 4260 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 420 ms | 4264 KB | Output is correct |
13 | Correct | 316 ms | 4180 KB | Output is correct |
14 | Correct | 272 ms | 4272 KB | Output is correct |
15 | Correct | 423 ms | 4264 KB | Output is correct |
16 | Correct | 337 ms | 4264 KB | Output is correct |
17 | Correct | 280 ms | 4260 KB | Output is correct |
18 | Correct | 400 ms | 4264 KB | Output is correct |
19 | Correct | 336 ms | 4256 KB | Output is correct |
20 | Correct | 272 ms | 4256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 224 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Incorrect | 1 ms | 340 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 224 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Incorrect | 1 ms | 340 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 224 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Incorrect | 1 ms | 340 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 478 ms | 4268 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 328 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 277 ms | 4256 KB | Output is correct |
6 | Correct | 278 ms | 4264 KB | Output is correct |
7 | Correct | 291 ms | 4260 KB | Output is correct |
8 | Correct | 270 ms | 4260 KB | Output is correct |
9 | Correct | 310 ms | 4180 KB | Output is correct |
10 | Correct | 281 ms | 4260 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 420 ms | 4264 KB | Output is correct |
13 | Correct | 316 ms | 4180 KB | Output is correct |
14 | Correct | 272 ms | 4272 KB | Output is correct |
15 | Correct | 423 ms | 4264 KB | Output is correct |
16 | Correct | 337 ms | 4264 KB | Output is correct |
17 | Correct | 280 ms | 4260 KB | Output is correct |
18 | Correct | 400 ms | 4264 KB | Output is correct |
19 | Correct | 336 ms | 4256 KB | Output is correct |
20 | Correct | 272 ms | 4256 KB | Output is correct |
21 | Correct | 0 ms | 224 KB | Output is correct |
22 | Correct | 0 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 0 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 0 ms | 340 KB | Output is correct |
29 | Incorrect | 1 ms | 340 KB | Output isn't correct |
30 | Halted | 0 ms | 0 KB | - |