답안 #806252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
806252 2023-08-04T05:30:37 Z vjudge1 Let's Win the Election (JOI22_ho_t3) C++17
33 / 100
1118 ms 8592 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);
                for(int j = 0; j <= t; j++) {
                    newdp[j] = dp[j] + c[i].first / t;
                    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 0 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 0 ms 212 KB Output is correct
5 Correct 922 ms 8488 KB Output is correct
6 Correct 900 ms 8356 KB Output is correct
7 Correct 995 ms 8476 KB Output is correct
8 Correct 949 ms 8488 KB Output is correct
9 Correct 893 ms 8476 KB Output is correct
10 Correct 889 ms 8576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 922 ms 8488 KB Output is correct
6 Correct 900 ms 8356 KB Output is correct
7 Correct 995 ms 8476 KB Output is correct
8 Correct 949 ms 8488 KB Output is correct
9 Correct 893 ms 8476 KB Output is correct
10 Correct 889 ms 8576 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1069 ms 8492 KB Output is correct
13 Correct 970 ms 8304 KB Output is correct
14 Correct 906 ms 8576 KB Output is correct
15 Correct 1118 ms 8488 KB Output is correct
16 Correct 941 ms 8504 KB Output is correct
17 Correct 919 ms 8592 KB Output is correct
18 Correct 1114 ms 8436 KB Output is correct
19 Correct 936 ms 8400 KB Output is correct
20 Correct 900 ms 8480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 0 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 0 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 336 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 0 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 0 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 328 ms 312 KB Output is correct
17 Correct 331 ms 312 KB Output is correct
18 Correct 312 ms 312 KB Output is correct
19 Correct 340 ms 212 KB Output is correct
20 Correct 358 ms 312 KB Output is correct
21 Correct 351 ms 312 KB Output is correct
22 Correct 385 ms 304 KB Output is correct
23 Correct 349 ms 308 KB Output is correct
24 Correct 387 ms 308 KB Output is correct
25 Correct 385 ms 316 KB Output is correct
26 Correct 374 ms 308 KB Output is correct
27 Correct 382 ms 308 KB Output is correct
28 Correct 360 ms 308 KB Output is correct
29 Correct 367 ms 312 KB Output is correct
30 Correct 358 ms 312 KB Output is correct
31 Correct 399 ms 308 KB Output is correct
32 Correct 373 ms 308 KB Output is correct
33 Correct 357 ms 212 KB Output is correct
34 Correct 336 ms 312 KB Output is correct
35 Correct 340 ms 312 KB Output is correct
36 Correct 321 ms 312 KB Output is correct
37 Correct 317 ms 308 KB Output is correct
38 Correct 316 ms 308 KB Output is correct
39 Correct 337 ms 312 KB Output is correct
40 Correct 307 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 0 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 0 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 328 ms 312 KB Output is correct
17 Correct 331 ms 312 KB Output is correct
18 Correct 312 ms 312 KB Output is correct
19 Correct 340 ms 212 KB Output is correct
20 Correct 358 ms 312 KB Output is correct
21 Correct 351 ms 312 KB Output is correct
22 Correct 385 ms 304 KB Output is correct
23 Correct 349 ms 308 KB Output is correct
24 Correct 387 ms 308 KB Output is correct
25 Correct 385 ms 316 KB Output is correct
26 Correct 374 ms 308 KB Output is correct
27 Correct 382 ms 308 KB Output is correct
28 Correct 360 ms 308 KB Output is correct
29 Correct 367 ms 312 KB Output is correct
30 Correct 358 ms 312 KB Output is correct
31 Correct 399 ms 308 KB Output is correct
32 Correct 373 ms 308 KB Output is correct
33 Correct 357 ms 212 KB Output is correct
34 Correct 336 ms 312 KB Output is correct
35 Correct 340 ms 312 KB Output is correct
36 Correct 321 ms 312 KB Output is correct
37 Correct 317 ms 308 KB Output is correct
38 Correct 316 ms 308 KB Output is correct
39 Correct 337 ms 312 KB Output is correct
40 Correct 307 ms 304 KB Output is correct
41 Incorrect 0 ms 212 KB Output isn't correct
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 521 ms 408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 922 ms 8488 KB Output is correct
6 Correct 900 ms 8356 KB Output is correct
7 Correct 995 ms 8476 KB Output is correct
8 Correct 949 ms 8488 KB Output is correct
9 Correct 893 ms 8476 KB Output is correct
10 Correct 889 ms 8576 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1069 ms 8492 KB Output is correct
13 Correct 970 ms 8304 KB Output is correct
14 Correct 906 ms 8576 KB Output is correct
15 Correct 1118 ms 8488 KB Output is correct
16 Correct 941 ms 8504 KB Output is correct
17 Correct 919 ms 8592 KB Output is correct
18 Correct 1114 ms 8436 KB Output is correct
19 Correct 936 ms 8400 KB Output is correct
20 Correct 900 ms 8480 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 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 0 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 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 328 ms 312 KB Output is correct
37 Correct 331 ms 312 KB Output is correct
38 Correct 312 ms 312 KB Output is correct
39 Correct 340 ms 212 KB Output is correct
40 Correct 358 ms 312 KB Output is correct
41 Correct 351 ms 312 KB Output is correct
42 Correct 385 ms 304 KB Output is correct
43 Correct 349 ms 308 KB Output is correct
44 Correct 387 ms 308 KB Output is correct
45 Correct 385 ms 316 KB Output is correct
46 Correct 374 ms 308 KB Output is correct
47 Correct 382 ms 308 KB Output is correct
48 Correct 360 ms 308 KB Output is correct
49 Correct 367 ms 312 KB Output is correct
50 Correct 358 ms 312 KB Output is correct
51 Correct 399 ms 308 KB Output is correct
52 Correct 373 ms 308 KB Output is correct
53 Correct 357 ms 212 KB Output is correct
54 Correct 336 ms 312 KB Output is correct
55 Correct 340 ms 312 KB Output is correct
56 Correct 321 ms 312 KB Output is correct
57 Correct 317 ms 308 KB Output is correct
58 Correct 316 ms 308 KB Output is correct
59 Correct 337 ms 312 KB Output is correct
60 Correct 307 ms 304 KB Output is correct
61 Incorrect 0 ms 212 KB Output isn't correct
62 Halted 0 ms 0 KB -