Submission #824418

# Submission time Handle Problem Language Result Execution time Memory
824418 2023-08-14T05:49:59 Z peteza Let's Win the Election (JOI22_ho_t3) C++14
10 / 100
596 ms 994480 KB
#include <bits/stdc++.h>
using namespace std;

int n, k;
bool vis[505][505][505];
double DP[505][505][505], inf = 1e12, cans = inf;
pair<int, int> dat[505];

int main() {
    DP[0][0][0] = 0; vis[0][0][0] = 1;
    cin >> n >> k;
    int bc = n;
    for(int i=0;i<n;i++) {
        cin >> dat[i].first >> dat[i].second;
        if(dat[i].second == -1) bc--, dat[i].second = INT_MAX;
    }
    sort(dat, dat+n, [](pair<int, int> a, pair<int, int> b){
        if(a.second == b.second) return a.first < b.first;
        return a.second < b.second;
    });
    for(int i=0;i<=n;i++) {
        for(int j=0;j<=k;j++) {
            for(int K=0;K<=bc;K++) {
                if(i == j && j == K && !i) continue;
                if(i == 0 || j<K) {DP[i][j][K] = inf; continue;}
                DP[i][j][K] = DP[i-1][j][K];
                if(j) DP[i][j][K] = min(DP[i][j][K], DP[i-1][j-1][K] + (1.00*dat[i-1].first/(K+1)));
                if(j && K && dat[i-1].second != INT_MAX) DP[i][j][K] = min(DP[i][j][K], DP[i-1][j-1][K-1] + (1.00*dat[i-1].second/K));                
            }
        }
    }
    for(int i=0;i<=bc;i++) cans = min(cans, DP[n][k][i]);
    cout << cans;
}
# 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 0 ms 340 KB Output is correct
5 Correct 35 ms 103044 KB Output is correct
6 Correct 85 ms 251256 KB Output is correct
7 Correct 162 ms 498300 KB Output is correct
8 Correct 235 ms 745420 KB Output is correct
9 Correct 312 ms 992556 KB Output is correct
10 Correct 196 ms 695984 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 0 ms 340 KB Output is correct
5 Correct 35 ms 103044 KB Output is correct
6 Correct 85 ms 251256 KB Output is correct
7 Correct 162 ms 498300 KB Output is correct
8 Correct 235 ms 745420 KB Output is correct
9 Correct 312 ms 992556 KB Output is correct
10 Correct 196 ms 695984 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 150 ms 302596 KB Output is correct
13 Correct 130 ms 301812 KB Output is correct
14 Correct 106 ms 301080 KB Output is correct
15 Correct 403 ms 698020 KB Output is correct
16 Correct 314 ms 697288 KB Output is correct
17 Correct 234 ms 696400 KB Output is correct
18 Correct 554 ms 994480 KB Output is correct
19 Correct 450 ms 993720 KB Output is correct
20 Correct 327 ms 992824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 0 ms 596 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Incorrect 0 ms 468 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 0 ms 340 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 0 ms 596 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Incorrect 0 ms 468 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 0 ms 340 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 0 ms 596 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Incorrect 0 ms 468 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 596 ms 994472 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 0 ms 340 KB Output is correct
5 Correct 35 ms 103044 KB Output is correct
6 Correct 85 ms 251256 KB Output is correct
7 Correct 162 ms 498300 KB Output is correct
8 Correct 235 ms 745420 KB Output is correct
9 Correct 312 ms 992556 KB Output is correct
10 Correct 196 ms 695984 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 150 ms 302596 KB Output is correct
13 Correct 130 ms 301812 KB Output is correct
14 Correct 106 ms 301080 KB Output is correct
15 Correct 403 ms 698020 KB Output is correct
16 Correct 314 ms 697288 KB Output is correct
17 Correct 234 ms 696400 KB Output is correct
18 Correct 554 ms 994480 KB Output is correct
19 Correct 450 ms 993720 KB Output is correct
20 Correct 327 ms 992824 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 0 ms 468 KB Output is correct
26 Correct 0 ms 468 KB Output is correct
27 Correct 0 ms 596 KB Output is correct
28 Correct 0 ms 468 KB Output is correct
29 Incorrect 0 ms 468 KB Output isn't correct
30 Halted 0 ms 0 KB -