답안 #572605

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572605 2022-06-04T19:26:28 Z JovanB Let's Win the Election (JOI22_ho_t3) C++17
100 / 100
527 ms 6348 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

const int N = 500;

ll dpm[N+5][N+5];
ld dp[N+5][N+5];
pair <int, int> a[N+5];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, k;
    cin >> n >> k;
    for(int i=1; i<=n; i++){
        cin >> a[i].first >> a[i].second;
        if(a[i].second == -1) a[i].second = 1005;
    }
    sort(a+1, a+1+n, [](pair <int, int> x, pair <int, int> y){ if(x.second == y.second) return x.first < y.first; return x.second < y.second; });
    for(int j=1; j<=n; j++) dpm[n+1][j] = 1e18;
    for(int i=n; i>=1; i--){
        for(int j=1; j<=n; j++){
            dpm[i][j] = dpm[i+1][j];
            dpm[i][j] = min(dpm[i][j], dpm[i+1][j-1] + a[i].first);
        }
    }
    ld res = 1e18;
    for(int t=0; t<=k; t++){
        for(int j=1; j<=t; j++) dp[0][j] = 1e18;
        for(int i=1; i<=n; i++){
            for(int j=0; j<=t; j++){
                dp[i][j] = dp[i-1][j] + 1.0*a[i].first/(t + 1);
                if(a[i].second != 1005 && j) dp[i][j] = min(dp[i][j], dp[i-1][j-1] + 1.0*a[i].second/j);
            }
        }
        for(int i=0; i<=n; i++){
            if(i >= t && k >= i) res = min(res, dp[i][t] + 1.0*dpm[i+1][k-i]/(t + 1));
        }
    }
    cout << res << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 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 5 ms 4692 KB Output is correct
6 Correct 17 ms 5260 KB Output is correct
7 Correct 57 ms 6220 KB Output is correct
8 Correct 135 ms 6204 KB Output is correct
9 Correct 225 ms 6148 KB Output is correct
10 Correct 109 ms 6164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 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 5 ms 4692 KB Output is correct
6 Correct 17 ms 5260 KB Output is correct
7 Correct 57 ms 6220 KB Output is correct
8 Correct 135 ms 6204 KB Output is correct
9 Correct 225 ms 6148 KB Output is correct
10 Correct 109 ms 6164 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 49 ms 5384 KB Output is correct
13 Correct 41 ms 5424 KB Output is correct
14 Correct 28 ms 5372 KB Output is correct
15 Correct 309 ms 6196 KB Output is correct
16 Correct 200 ms 6316 KB Output is correct
17 Correct 135 ms 6144 KB Output is correct
18 Correct 512 ms 6272 KB Output is correct
19 Correct 401 ms 6148 KB Output is correct
20 Correct 265 ms 6248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 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 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 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 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 532 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 0 ms 456 KB Output is correct
26 Correct 0 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 0 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 464 KB Output is correct
36 Correct 0 ms 468 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 1 ms 464 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 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 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 532 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 0 ms 456 KB Output is correct
26 Correct 0 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 0 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 464 KB Output is correct
36 Correct 0 ms 468 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 1 ms 464 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 1 ms 468 KB Output is correct
41 Correct 1 ms 1096 KB Output is correct
42 Correct 1 ms 1108 KB Output is correct
43 Correct 2 ms 1108 KB Output is correct
44 Correct 1 ms 1096 KB Output is correct
45 Correct 2 ms 1108 KB Output is correct
46 Correct 2 ms 1108 KB Output is correct
47 Correct 3 ms 1236 KB Output is correct
48 Correct 3 ms 1224 KB Output is correct
49 Correct 4 ms 1236 KB Output is correct
50 Correct 3 ms 1236 KB Output is correct
51 Correct 5 ms 1236 KB Output is correct
52 Correct 4 ms 1228 KB Output is correct
53 Correct 3 ms 1236 KB Output is correct
54 Correct 3 ms 1236 KB Output is correct
55 Correct 3 ms 1228 KB Output is correct
56 Correct 3 ms 1236 KB Output is correct
57 Correct 2 ms 1236 KB Output is correct
58 Correct 2 ms 1236 KB Output is correct
59 Correct 3 ms 1236 KB Output is correct
60 Correct 2 ms 1236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 515 ms 6248 KB Output is correct
2 Correct 509 ms 6252 KB Output is correct
3 Correct 527 ms 6252 KB Output is correct
4 Correct 505 ms 6348 KB Output is correct
5 Correct 522 ms 6312 KB Output is correct
6 Correct 512 ms 6252 KB Output is correct
7 Correct 506 ms 6180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 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 5 ms 4692 KB Output is correct
6 Correct 17 ms 5260 KB Output is correct
7 Correct 57 ms 6220 KB Output is correct
8 Correct 135 ms 6204 KB Output is correct
9 Correct 225 ms 6148 KB Output is correct
10 Correct 109 ms 6164 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 49 ms 5384 KB Output is correct
13 Correct 41 ms 5424 KB Output is correct
14 Correct 28 ms 5372 KB Output is correct
15 Correct 309 ms 6196 KB Output is correct
16 Correct 200 ms 6316 KB Output is correct
17 Correct 135 ms 6144 KB Output is correct
18 Correct 512 ms 6272 KB Output is correct
19 Correct 401 ms 6148 KB Output is correct
20 Correct 265 ms 6248 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 340 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 0 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 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 532 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 1 ms 468 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 1 ms 468 KB Output is correct
41 Correct 1 ms 468 KB Output is correct
42 Correct 1 ms 464 KB Output is correct
43 Correct 1 ms 460 KB Output is correct
44 Correct 1 ms 460 KB Output is correct
45 Correct 0 ms 456 KB Output is correct
46 Correct 0 ms 468 KB Output is correct
47 Correct 1 ms 468 KB Output is correct
48 Correct 1 ms 468 KB Output is correct
49 Correct 1 ms 468 KB Output is correct
50 Correct 1 ms 468 KB Output is correct
51 Correct 1 ms 468 KB Output is correct
52 Correct 0 ms 468 KB Output is correct
53 Correct 1 ms 468 KB Output is correct
54 Correct 1 ms 468 KB Output is correct
55 Correct 1 ms 464 KB Output is correct
56 Correct 0 ms 468 KB Output is correct
57 Correct 1 ms 468 KB Output is correct
58 Correct 1 ms 464 KB Output is correct
59 Correct 1 ms 596 KB Output is correct
60 Correct 1 ms 468 KB Output is correct
61 Correct 1 ms 1096 KB Output is correct
62 Correct 1 ms 1108 KB Output is correct
63 Correct 2 ms 1108 KB Output is correct
64 Correct 1 ms 1096 KB Output is correct
65 Correct 2 ms 1108 KB Output is correct
66 Correct 2 ms 1108 KB Output is correct
67 Correct 3 ms 1236 KB Output is correct
68 Correct 3 ms 1224 KB Output is correct
69 Correct 4 ms 1236 KB Output is correct
70 Correct 3 ms 1236 KB Output is correct
71 Correct 5 ms 1236 KB Output is correct
72 Correct 4 ms 1228 KB Output is correct
73 Correct 3 ms 1236 KB Output is correct
74 Correct 3 ms 1236 KB Output is correct
75 Correct 3 ms 1228 KB Output is correct
76 Correct 3 ms 1236 KB Output is correct
77 Correct 2 ms 1236 KB Output is correct
78 Correct 2 ms 1236 KB Output is correct
79 Correct 3 ms 1236 KB Output is correct
80 Correct 2 ms 1236 KB Output is correct
81 Correct 515 ms 6248 KB Output is correct
82 Correct 509 ms 6252 KB Output is correct
83 Correct 527 ms 6252 KB Output is correct
84 Correct 505 ms 6348 KB Output is correct
85 Correct 522 ms 6312 KB Output is correct
86 Correct 512 ms 6252 KB Output is correct
87 Correct 506 ms 6180 KB Output is correct
88 Correct 8 ms 4692 KB Output is correct
89 Correct 8 ms 4692 KB Output is correct
90 Correct 35 ms 5196 KB Output is correct
91 Correct 35 ms 5260 KB Output is correct
92 Correct 129 ms 6200 KB Output is correct
93 Correct 132 ms 6220 KB Output is correct
94 Correct 292 ms 6156 KB Output is correct
95 Correct 388 ms 6228 KB Output is correct
96 Correct 411 ms 6316 KB Output is correct
97 Correct 422 ms 6256 KB Output is correct
98 Correct 252 ms 6252 KB Output is correct
99 Correct 257 ms 6256 KB Output is correct
100 Correct 258 ms 6160 KB Output is correct
101 Correct 256 ms 6320 KB Output is correct
102 Correct 248 ms 6256 KB Output is correct
103 Correct 246 ms 6224 KB Output is correct
104 Correct 283 ms 6252 KB Output is correct
105 Correct 247 ms 6248 KB Output is correct