답안 #806276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
806276 2023-08-04T05:37:18 Z vjudge1 Let's Win the Election (JOI22_ho_t3) C++17
44 / 100
1166 ms 8680 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

const int N = 500;
const ld INF = 1e16;

int n, k;
pair<ld, ld> c[N + 10];
bool is1Subtask = 1;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        cin >> c[i].first >> c[i].second;
        if(c[i].second == -1) c[i].second = INF;
        is1Subtask &= (c[i].second == c[i].first || c[i].second == INF);
    }
    sort(c + 1, c + n + 1, [](pair<ld, ld> x, pair<ld, ld> y) {return x.second < y.second;});
    if(is1Subtask) {
        vector<vector<ld>> dp(n + 1, vector<ld>(n + 1, INF));
        dp[0][1] = 0;
        for(int i = 1; i <= n; i++) {
            vector<vector<ld>> newdp = dp;
            for(int k = 1; k <= i; k++) {
                for(int v = 1; v <= i + 1; v++) {
                    newdp[k][v] = min(newdp[k][v], dp[k - 1][v] + c[i].first / v); 
                    if(v > 1 && c[i].second != INF) 
                        newdp[k][v] = min(newdp[k][v], dp[k - 1][v - 1] + c[i].second / (v - 1)) ;
                }
            }
            dp = newdp;
        }
        ld res = INF;
        for(int v = 1; v <= n; v++) {
            res = min(res, dp[k][v]);
        }
        cout << setprecision(9) << fixed << res ;
        return 0;
    }
    if(n <= 20) {
        ld res = INF;
        for(int msk = 0; msk < (1 << n); msk++) {
            vector<ll> v;
            vector<ll> w(n + 1, -1);
            ld sum = 0, veloc = 1;
            for(int i = 0; i < n; i++) {
                if(msk >> i & 1) {
                    sum += c[i + 1].second / veloc;
                    veloc++;
                } else {
                    v.push_back(c[i + 1].first);
                }
            }
            sort(v.begin(), v.end());
            for(int i = 0; i <= k - veloc; i++) 
                sum += v[i] / veloc;
            res = min(res, sum);
        }
        cout << setprecision(9) << fixed << res ;
        return 0;
    }
    if(n == k) {
        ld res = INF;
        for(int t = 0; t <= n; t++) {
            vector<ld> dp(t + 1, INF);
            dp[0] = 0;
            for(int i = 1; i <= n; i++) {
                vector<ld> newdp(t + 1, INF);
                for(int j = 0; j <= t; j++) {
                    newdp[j] = min(newdp[j], dp[j] + c[i].first / (t + 1));
                    if(j) newdp[j] = min(newdp[j], dp[j - 1] + c[i].second / j);
                }
                dp = newdp;
            }
            res = min(res, dp[t]);
        }
        cout << setprecision(9) << fixed << res ;
        return 0;
    }
}  
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 991 ms 8472 KB Output is correct
6 Correct 1050 ms 8680 KB Output is correct
7 Correct 908 ms 8468 KB Output is correct
8 Correct 991 ms 8420 KB Output is correct
9 Correct 1068 ms 8436 KB Output is correct
10 Correct 1042 ms 8456 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 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 991 ms 8472 KB Output is correct
6 Correct 1050 ms 8680 KB Output is correct
7 Correct 908 ms 8468 KB Output is correct
8 Correct 991 ms 8420 KB Output is correct
9 Correct 1068 ms 8436 KB Output is correct
10 Correct 1042 ms 8456 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1134 ms 8460 KB Output is correct
13 Correct 1084 ms 8508 KB Output is correct
14 Correct 959 ms 8480 KB Output is correct
15 Correct 1127 ms 8488 KB Output is correct
16 Correct 1108 ms 8428 KB Output is correct
17 Correct 1012 ms 8328 KB Output is correct
18 Correct 1166 ms 8404 KB Output is correct
19 Correct 1093 ms 8484 KB Output is correct
20 Correct 1027 ms 8484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 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 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 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 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 366 ms 324 KB Output is correct
17 Correct 340 ms 312 KB Output is correct
18 Correct 314 ms 312 KB Output is correct
19 Correct 353 ms 316 KB Output is correct
20 Correct 348 ms 308 KB Output is correct
21 Correct 343 ms 212 KB Output is correct
22 Correct 379 ms 316 KB Output is correct
23 Correct 353 ms 316 KB Output is correct
24 Correct 357 ms 316 KB Output is correct
25 Correct 420 ms 312 KB Output is correct
26 Correct 392 ms 328 KB Output is correct
27 Correct 379 ms 316 KB Output is correct
28 Correct 404 ms 312 KB Output is correct
29 Correct 360 ms 312 KB Output is correct
30 Correct 381 ms 312 KB Output is correct
31 Correct 386 ms 312 KB Output is correct
32 Correct 370 ms 308 KB Output is correct
33 Correct 372 ms 312 KB Output is correct
34 Correct 351 ms 212 KB Output is correct
35 Correct 342 ms 212 KB Output is correct
36 Correct 348 ms 320 KB Output is correct
37 Correct 338 ms 316 KB Output is correct
38 Correct 342 ms 328 KB Output is correct
39 Correct 319 ms 324 KB Output is correct
40 Correct 358 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 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 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 366 ms 324 KB Output is correct
17 Correct 340 ms 312 KB Output is correct
18 Correct 314 ms 312 KB Output is correct
19 Correct 353 ms 316 KB Output is correct
20 Correct 348 ms 308 KB Output is correct
21 Correct 343 ms 212 KB Output is correct
22 Correct 379 ms 316 KB Output is correct
23 Correct 353 ms 316 KB Output is correct
24 Correct 357 ms 316 KB Output is correct
25 Correct 420 ms 312 KB Output is correct
26 Correct 392 ms 328 KB Output is correct
27 Correct 379 ms 316 KB Output is correct
28 Correct 404 ms 312 KB Output is correct
29 Correct 360 ms 312 KB Output is correct
30 Correct 381 ms 312 KB Output is correct
31 Correct 386 ms 312 KB Output is correct
32 Correct 370 ms 308 KB Output is correct
33 Correct 372 ms 312 KB Output is correct
34 Correct 351 ms 212 KB Output is correct
35 Correct 342 ms 212 KB Output is correct
36 Correct 348 ms 320 KB Output is correct
37 Correct 338 ms 316 KB Output is correct
38 Correct 342 ms 328 KB Output is correct
39 Correct 319 ms 324 KB Output is correct
40 Correct 358 ms 312 KB Output is correct
41 Incorrect 1 ms 244 KB Output isn't correct
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 787 ms 408 KB Output is correct
2 Correct 787 ms 404 KB Output is correct
3 Correct 803 ms 408 KB Output is correct
4 Correct 824 ms 412 KB Output is correct
5 Correct 829 ms 508 KB Output is correct
6 Correct 874 ms 416 KB Output is correct
7 Correct 947 ms 408 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 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 991 ms 8472 KB Output is correct
6 Correct 1050 ms 8680 KB Output is correct
7 Correct 908 ms 8468 KB Output is correct
8 Correct 991 ms 8420 KB Output is correct
9 Correct 1068 ms 8436 KB Output is correct
10 Correct 1042 ms 8456 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1134 ms 8460 KB Output is correct
13 Correct 1084 ms 8508 KB Output is correct
14 Correct 959 ms 8480 KB Output is correct
15 Correct 1127 ms 8488 KB Output is correct
16 Correct 1108 ms 8428 KB Output is correct
17 Correct 1012 ms 8328 KB Output is correct
18 Correct 1166 ms 8404 KB Output is correct
19 Correct 1093 ms 8484 KB Output is correct
20 Correct 1027 ms 8484 KB Output is correct
21 Correct 1 ms 324 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 320 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 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 0 ms 212 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 320 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 366 ms 324 KB Output is correct
37 Correct 340 ms 312 KB Output is correct
38 Correct 314 ms 312 KB Output is correct
39 Correct 353 ms 316 KB Output is correct
40 Correct 348 ms 308 KB Output is correct
41 Correct 343 ms 212 KB Output is correct
42 Correct 379 ms 316 KB Output is correct
43 Correct 353 ms 316 KB Output is correct
44 Correct 357 ms 316 KB Output is correct
45 Correct 420 ms 312 KB Output is correct
46 Correct 392 ms 328 KB Output is correct
47 Correct 379 ms 316 KB Output is correct
48 Correct 404 ms 312 KB Output is correct
49 Correct 360 ms 312 KB Output is correct
50 Correct 381 ms 312 KB Output is correct
51 Correct 386 ms 312 KB Output is correct
52 Correct 370 ms 308 KB Output is correct
53 Correct 372 ms 312 KB Output is correct
54 Correct 351 ms 212 KB Output is correct
55 Correct 342 ms 212 KB Output is correct
56 Correct 348 ms 320 KB Output is correct
57 Correct 338 ms 316 KB Output is correct
58 Correct 342 ms 328 KB Output is correct
59 Correct 319 ms 324 KB Output is correct
60 Correct 358 ms 312 KB Output is correct
61 Incorrect 1 ms 244 KB Output isn't correct
62 Halted 0 ms 0 KB -