답안 #880014

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880014 2023-11-28T15:05:48 Z frostray8653 Let's Win the Election (JOI22_ho_t3) C++17
100 / 100
613 ms 3108 KB
#include <bits/stdc++.h>
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
using pii = pair<int, int>;

const int N = 505;
const int INF = 1e9;
const double dINF = 1e9;
pii a[N];
int n, tar;

/// 共有 cnt 個助選人
double calc(int cnt) {
    vector<vector<double>> dp(n + 1, vector<double>(n + 1, dINF));
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = tar; j >= 1; j--)
            dp[j][cnt] = min(dp[j][cnt], dp[j - 1][cnt] + (double)a[i].first / (cnt + 1));
        
        for (int j = cnt; j >= 0; j--) {
            if (j != cnt)
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + (double)a[i].first / (cnt + 1));
            if (j && a[i].second < INF)
                dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (double)a[i].second / j);
        }
    }
    return dp[tar][cnt];
}

signed main() {
    IO;
    
    cin >> n >> tar;
    FOR(i, 1, n) {
        cin >> a[i].first >> a[i].second;
        if (a[i].second == -1)
            a[i].second = INF;
    }
    sort(a + 1, a + n + 1, [&](pii p, pii q) {
        return p.second < q.second;
    });
    
    double ans = dINF;
    for (int i = 0; i <= tar; i++)
        ans = min(ans, calc(i));
    cout << fixed << setprecision(15) << ans << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 28 ms 2588 KB Output is correct
6 Correct 79 ms 2628 KB Output is correct
7 Correct 183 ms 2612 KB Output is correct
8 Correct 323 ms 2752 KB Output is correct
9 Correct 496 ms 2636 KB Output is correct
10 Correct 282 ms 2468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 28 ms 2588 KB Output is correct
6 Correct 79 ms 2628 KB Output is correct
7 Correct 183 ms 2612 KB Output is correct
8 Correct 323 ms 2752 KB Output is correct
9 Correct 496 ms 2636 KB Output is correct
10 Correct 282 ms 2468 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 110 ms 2636 KB Output is correct
13 Correct 99 ms 2628 KB Output is correct
14 Correct 103 ms 2640 KB Output is correct
15 Correct 331 ms 2560 KB Output is correct
16 Correct 314 ms 2708 KB Output is correct
17 Correct 296 ms 2588 KB Output is correct
18 Correct 613 ms 2856 KB Output is correct
19 Correct 556 ms 2692 KB Output is correct
20 Correct 537 ms 2760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 548 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 352 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 464 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 548 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 352 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 464 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 2 ms 348 KB Output is correct
44 Correct 1 ms 344 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 2 ms 348 KB Output is correct
48 Correct 1 ms 460 KB Output is correct
49 Correct 2 ms 348 KB Output is correct
50 Correct 2 ms 348 KB Output is correct
51 Correct 5 ms 344 KB Output is correct
52 Correct 5 ms 348 KB Output is correct
53 Correct 2 ms 348 KB Output is correct
54 Correct 2 ms 344 KB Output is correct
55 Correct 2 ms 348 KB Output is correct
56 Correct 2 ms 348 KB Output is correct
57 Correct 2 ms 348 KB Output is correct
58 Correct 2 ms 348 KB Output is correct
59 Correct 2 ms 348 KB Output is correct
60 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 604 ms 2616 KB Output is correct
2 Correct 592 ms 2692 KB Output is correct
3 Correct 600 ms 2708 KB Output is correct
4 Correct 600 ms 2444 KB Output is correct
5 Correct 594 ms 2988 KB Output is correct
6 Correct 596 ms 2824 KB Output is correct
7 Correct 595 ms 2660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 28 ms 2588 KB Output is correct
6 Correct 79 ms 2628 KB Output is correct
7 Correct 183 ms 2612 KB Output is correct
8 Correct 323 ms 2752 KB Output is correct
9 Correct 496 ms 2636 KB Output is correct
10 Correct 282 ms 2468 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 110 ms 2636 KB Output is correct
13 Correct 99 ms 2628 KB Output is correct
14 Correct 103 ms 2640 KB Output is correct
15 Correct 331 ms 2560 KB Output is correct
16 Correct 314 ms 2708 KB Output is correct
17 Correct 296 ms 2588 KB Output is correct
18 Correct 613 ms 2856 KB Output is correct
19 Correct 556 ms 2692 KB Output is correct
20 Correct 537 ms 2760 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 548 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 344 KB Output is correct
51 Correct 1 ms 460 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 352 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 1 ms 344 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 0 ms 464 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 1 ms 344 KB Output is correct
63 Correct 2 ms 348 KB Output is correct
64 Correct 1 ms 344 KB Output is correct
65 Correct 1 ms 348 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 2 ms 348 KB Output is correct
68 Correct 1 ms 460 KB Output is correct
69 Correct 2 ms 348 KB Output is correct
70 Correct 2 ms 348 KB Output is correct
71 Correct 5 ms 344 KB Output is correct
72 Correct 5 ms 348 KB Output is correct
73 Correct 2 ms 348 KB Output is correct
74 Correct 2 ms 344 KB Output is correct
75 Correct 2 ms 348 KB Output is correct
76 Correct 2 ms 348 KB Output is correct
77 Correct 2 ms 348 KB Output is correct
78 Correct 2 ms 348 KB Output is correct
79 Correct 2 ms 348 KB Output is correct
80 Correct 2 ms 348 KB Output is correct
81 Correct 604 ms 2616 KB Output is correct
82 Correct 592 ms 2692 KB Output is correct
83 Correct 600 ms 2708 KB Output is correct
84 Correct 600 ms 2444 KB Output is correct
85 Correct 594 ms 2988 KB Output is correct
86 Correct 596 ms 2824 KB Output is correct
87 Correct 595 ms 2660 KB Output is correct
88 Correct 30 ms 2580 KB Output is correct
89 Correct 29 ms 2580 KB Output is correct
90 Correct 82 ms 2720 KB Output is correct
91 Correct 84 ms 2696 KB Output is correct
92 Correct 219 ms 2764 KB Output is correct
93 Correct 200 ms 2628 KB Output is correct
94 Correct 376 ms 2632 KB Output is correct
95 Correct 394 ms 2592 KB Output is correct
96 Correct 512 ms 2808 KB Output is correct
97 Correct 507 ms 2560 KB Output is correct
98 Correct 332 ms 2624 KB Output is correct
99 Correct 328 ms 2584 KB Output is correct
100 Correct 328 ms 2684 KB Output is correct
101 Correct 330 ms 2572 KB Output is correct
102 Correct 334 ms 3108 KB Output is correct
103 Correct 333 ms 2652 KB Output is correct
104 Correct 336 ms 2732 KB Output is correct
105 Correct 330 ms 2768 KB Output is correct