Submission #715307

# Submission time Handle Problem Language Result Execution time Memory
715307 2023-03-26T12:01:17 Z ac2hu Let's Win the Election (JOI22_ho_t3) C++14
10 / 100
414 ms 8324 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 500 + 10;
using ld = long double;
void pmin(ld &a, ld c){a = min(a, c);}
struct cst{int a, b;} c[N];
int n, k;
ld odp[N][N], ndp[N][N];
signed main() {
    iostream::sync_with_stdio(false);
    cin.tie(0);cout.tie(0); cout << setprecision(10) << fixed;
    cin >> n >> k;
    for(int i = 0;i<n;i++)cin >> c[i + 1].a >> c[i + 1].b;
    for(int i = 0;i<n;i++)if(c[i + 1].b == -1)c[i + 1].b = 1e9;
    sort(c + 1, c + n + 1, [&](cst a, cst b){
        if(a.b == b.b)return a.a < b.a;
        return a.b < b.b;
    });
    for(int i = 0;i<n;i++)if(c[i + 1].b == 1e9)c[i + 1].b = -1;
    for(int i = 0;i<=n;i++)for(int j = 0;j<=n;j++)odp[i][j] = ndp[i][j] = 1e18;
    odp[0][0] = 0; 
    for(int i = 1;i<=n;i++){
        for(int places = 0;places<=min(i, k);places++){
            for(int collab = 0;collab<=places;collab++){
                ndp[places][collab] = odp[places][collab];
                if(places != 0){
                    pmin(ndp[places][collab], odp[places - 1][collab] + ((ld)c[i].a)/(collab + 1));
                }
                if(collab != 0 && c[i].b != -1){
                    pmin(ndp[places][collab], odp[places - 1][collab - 1] + ((ld)c[i].b)/(collab));
                }
            }
        }
        for(int c = 0;c<=i;c++){
            for(int k = 0;k<=i;k++)odp[c][k] = ndp[c][k];
        }
    }
    ld mn = 1e18;
    for(int collab = 0;collab<=k;collab++)pmin(mn, ndp[k][collab]);
    cout << mn << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 78 ms 8312 KB Output is correct
6 Correct 102 ms 8312 KB Output is correct
7 Correct 204 ms 8276 KB Output is correct
8 Correct 241 ms 8312 KB Output is correct
9 Correct 273 ms 8312 KB Output is correct
10 Correct 191 ms 8316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 78 ms 8312 KB Output is correct
6 Correct 102 ms 8312 KB Output is correct
7 Correct 204 ms 8276 KB Output is correct
8 Correct 241 ms 8312 KB Output is correct
9 Correct 273 ms 8312 KB Output is correct
10 Correct 191 ms 8316 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 148 ms 8308 KB Output is correct
13 Correct 113 ms 8316 KB Output is correct
14 Correct 107 ms 8308 KB Output is correct
15 Correct 328 ms 8312 KB Output is correct
16 Correct 255 ms 8316 KB Output is correct
17 Correct 229 ms 8308 KB Output is correct
18 Correct 409 ms 8312 KB Output is correct
19 Correct 285 ms 8308 KB Output is correct
20 Correct 236 ms 8324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 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 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 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 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 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 414 ms 8308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 78 ms 8312 KB Output is correct
6 Correct 102 ms 8312 KB Output is correct
7 Correct 204 ms 8276 KB Output is correct
8 Correct 241 ms 8312 KB Output is correct
9 Correct 273 ms 8312 KB Output is correct
10 Correct 191 ms 8316 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 148 ms 8308 KB Output is correct
13 Correct 113 ms 8316 KB Output is correct
14 Correct 107 ms 8308 KB Output is correct
15 Correct 328 ms 8312 KB Output is correct
16 Correct 255 ms 8316 KB Output is correct
17 Correct 229 ms 8308 KB Output is correct
18 Correct 409 ms 8312 KB Output is correct
19 Correct 285 ms 8308 KB Output is correct
20 Correct 236 ms 8324 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 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 -