답안 #587103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587103 2022-07-01T10:09:28 Z rgnerdplayer Let's Win the Election (JOI22_ho_t3) C++17
56 / 100
2500 ms 1156 KB
#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    auto solve = [&]() {
        int n, k;
        cin >> n >> k;

        vector<int> a(n), b(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i] >> b[i];
            if (b[i] == -1) {
                b[i] = 1e9;
            }
        }

        vector<int> ord(n);
        iota(ord.begin(), ord.end(), 0);
        sort(ord.begin(), ord.end(), [&](auto i, auto j) {
            return pair(b[i], a[i]) < pair(b[j], a[j]);
        });

        // dp[i][votes][coord]
        double ans = 1e9;

        for (int x = 0; x <= k; x++) {
            vector dp(k + 1, vector<double>(x + 1, 1e9)), ndp(dp);
            dp[0][0] = 0;
            for (auto i : ord) {
                ndp = dp;
                for (int v = 0; v < k; v++) {
                    for (int c = 0; c <= x; c++) {
                        dp[v + 1][c] = min(dp[v + 1][c], ndp[v][c] + 1.0 * a[i] / (x + 1));
                        if (c < x) {
                            dp[v + 1][c + 1] = min(dp[v + 1][c + 1], ndp[v][c] + 1.0 * b[i] / (c + 1));
                        }
                    }
                }
            }
            ans = min(ans, dp[k][x]);
        }

        cout << fixed << setprecision(9) << ans << '\n';
    };
    
    solve();
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 87 ms 344 KB Output is correct
6 Correct 1240 ms 880 KB Output is correct
7 Execution timed out 2571 ms 1152 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 87 ms 344 KB Output is correct
6 Correct 1240 ms 880 KB Output is correct
7 Execution timed out 2571 ms 1152 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 316 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 316 KB Output is correct
23 Correct 1 ms 324 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 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 316 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 316 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 316 KB Output is correct
23 Correct 1 ms 324 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 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 316 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 4 ms 340 KB Output is correct
44 Correct 5 ms 340 KB Output is correct
45 Correct 17 ms 340 KB Output is correct
46 Correct 18 ms 392 KB Output is correct
47 Correct 37 ms 432 KB Output is correct
48 Correct 41 ms 424 KB Output is correct
49 Correct 75 ms 480 KB Output is correct
50 Correct 68 ms 460 KB Output is correct
51 Correct 133 ms 632 KB Output is correct
52 Correct 145 ms 592 KB Output is correct
53 Correct 45 ms 460 KB Output is correct
54 Correct 38 ms 376 KB Output is correct
55 Correct 37 ms 376 KB Output is correct
56 Correct 36 ms 368 KB Output is correct
57 Correct 37 ms 452 KB Output is correct
58 Correct 40 ms 444 KB Output is correct
59 Correct 37 ms 416 KB Output is correct
60 Correct 38 ms 372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2593 ms 1156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 87 ms 344 KB Output is correct
6 Correct 1240 ms 880 KB Output is correct
7 Execution timed out 2571 ms 1152 KB Time limit exceeded
8 Halted 0 ms 0 KB -