답안 #957565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
957565 2024-04-04T03:36:52 Z Pring Let's Win the Election (JOI22_ho_t3) C++17
100 / 100
109 ms 3672 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

// #define int long long
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;

const int MXN = 505;
int n, k;
pii p[MXN];

int suf[MXN][MXN];
double dp[MXN][MXN];

void GET_SUF() {
    vector<int> v;
    for (int i = n; i > 0; i--) {
        v.push_back(p[i].fs);
        sort(v.begin(), v.end());
        suf[i][0] = 0;
        FOR(j, 0, v.size()) suf[i][j + 1] = suf[i][j] + v[j];
    }
}

double calc(int g) {
    dp[0][0] = 0.0;
    FOR(j, 1, g + 1) dp[0][j] = 3.9e239;
    FOR(i, 1, k + 1) {
        dp[i][0] = dp[i - 1][0] + (double) p[i].fs / (g + 1);
        FOR(j, 1, g + 1) {
            dp[i][j] = min(dp[i - 1][j] + (double) p[i].fs / (g + 1), dp[i - 1][j - 1] + (double) p[i].sc / j);
        }
    }
    // FOR(j, 0, g + 1) {
    //     FOR(i, 0, k + 1) cout << setw(8) << dp[i][j] << ' ';
    //     cout << endl;
    // }
    // cout << endl;
    double ans = 3.9e239;
    FOR(i, 0, k + 1) ans = min(ans, dp[i][g] + (double) suf[i + 1][k - i] / (g + 1));
    return ans;
}

void miku() {
    cin >> n >> k;
    FOR(i, 1, n + 1) {
        cin >> p[i].fs >> p[i].sc;
        if (p[i].sc == -1) p[i].sc = 2e9;
    }
    sort(p + 1, p + n + 1, [](pii a, pii b) -> bool {
        return a.sc < b.sc;
    });
    GET_SUF();
    double ans = 3.9e239;
    FOR(g, 0, k + 1) {
        double x = calc(g);
        debug(g, x);
        ans = min(ans, x);
    }
    cout << fixed << setprecision(10) << ans << '\n';
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    miku();
    return 0;
}

Compilation message

Main.cpp: In function 'void miku()':
Main.cpp:11:20: warning: statement has no effect [-Wunused-value]
   11 | #define debug(...) 39
      |                    ^~
Main.cpp:70:9: note: in expansion of macro 'debug'
   70 |         debug(g, x);
      |         ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 3 ms 3420 KB Output is correct
6 Correct 5 ms 3420 KB Output is correct
7 Correct 16 ms 3460 KB Output is correct
8 Correct 44 ms 3420 KB Output is correct
9 Correct 100 ms 3416 KB Output is correct
10 Correct 38 ms 3444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 3 ms 3420 KB Output is correct
6 Correct 5 ms 3420 KB Output is correct
7 Correct 16 ms 3460 KB Output is correct
8 Correct 44 ms 3420 KB Output is correct
9 Correct 100 ms 3416 KB Output is correct
10 Correct 38 ms 3444 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 7 ms 3428 KB Output is correct
13 Correct 6 ms 3456 KB Output is correct
14 Correct 6 ms 3296 KB Output is correct
15 Correct 38 ms 3420 KB Output is correct
16 Correct 37 ms 3420 KB Output is correct
17 Correct 37 ms 3420 KB Output is correct
18 Correct 103 ms 3420 KB Output is correct
19 Correct 104 ms 3420 KB Output is correct
20 Correct 101 ms 3420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2392 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2392 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2512 KB Output is correct
46 Correct 1 ms 2652 KB Output is correct
47 Correct 1 ms 2664 KB Output is correct
48 Correct 1 ms 2652 KB Output is correct
49 Correct 1 ms 2652 KB Output is correct
50 Correct 2 ms 2652 KB Output is correct
51 Correct 2 ms 2652 KB Output is correct
52 Correct 2 ms 2652 KB Output is correct
53 Correct 2 ms 2652 KB Output is correct
54 Correct 1 ms 2652 KB Output is correct
55 Correct 1 ms 2648 KB Output is correct
56 Correct 1 ms 2652 KB Output is correct
57 Correct 2 ms 2652 KB Output is correct
58 Correct 1 ms 2652 KB Output is correct
59 Correct 1 ms 2904 KB Output is correct
60 Correct 1 ms 2904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 101 ms 3428 KB Output is correct
2 Correct 101 ms 3420 KB Output is correct
3 Correct 102 ms 3664 KB Output is correct
4 Correct 101 ms 3416 KB Output is correct
5 Correct 109 ms 3416 KB Output is correct
6 Correct 99 ms 3416 KB Output is correct
7 Correct 103 ms 3432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 3 ms 3420 KB Output is correct
6 Correct 5 ms 3420 KB Output is correct
7 Correct 16 ms 3460 KB Output is correct
8 Correct 44 ms 3420 KB Output is correct
9 Correct 100 ms 3416 KB Output is correct
10 Correct 38 ms 3444 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 7 ms 3428 KB Output is correct
13 Correct 6 ms 3456 KB Output is correct
14 Correct 6 ms 3296 KB Output is correct
15 Correct 38 ms 3420 KB Output is correct
16 Correct 37 ms 3420 KB Output is correct
17 Correct 37 ms 3420 KB Output is correct
18 Correct 103 ms 3420 KB Output is correct
19 Correct 104 ms 3420 KB Output is correct
20 Correct 101 ms 3420 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2392 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 1 ms 2392 KB Output is correct
52 Correct 1 ms 2392 KB Output is correct
53 Correct 1 ms 2396 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 2392 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 1 ms 2396 KB Output is correct
62 Correct 1 ms 2396 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2396 KB Output is correct
65 Correct 1 ms 2512 KB Output is correct
66 Correct 1 ms 2652 KB Output is correct
67 Correct 1 ms 2664 KB Output is correct
68 Correct 1 ms 2652 KB Output is correct
69 Correct 1 ms 2652 KB Output is correct
70 Correct 2 ms 2652 KB Output is correct
71 Correct 2 ms 2652 KB Output is correct
72 Correct 2 ms 2652 KB Output is correct
73 Correct 2 ms 2652 KB Output is correct
74 Correct 1 ms 2652 KB Output is correct
75 Correct 1 ms 2648 KB Output is correct
76 Correct 1 ms 2652 KB Output is correct
77 Correct 2 ms 2652 KB Output is correct
78 Correct 1 ms 2652 KB Output is correct
79 Correct 1 ms 2904 KB Output is correct
80 Correct 1 ms 2904 KB Output is correct
81 Correct 101 ms 3428 KB Output is correct
82 Correct 101 ms 3420 KB Output is correct
83 Correct 102 ms 3664 KB Output is correct
84 Correct 101 ms 3416 KB Output is correct
85 Correct 109 ms 3416 KB Output is correct
86 Correct 99 ms 3416 KB Output is correct
87 Correct 103 ms 3432 KB Output is correct
88 Correct 4 ms 3416 KB Output is correct
89 Correct 4 ms 3420 KB Output is correct
90 Correct 5 ms 3420 KB Output is correct
91 Correct 5 ms 3388 KB Output is correct
92 Correct 16 ms 3416 KB Output is correct
93 Correct 16 ms 3420 KB Output is correct
94 Correct 45 ms 3440 KB Output is correct
95 Correct 47 ms 3576 KB Output is correct
96 Correct 74 ms 3416 KB Output is correct
97 Correct 74 ms 3420 KB Output is correct
98 Correct 39 ms 3420 KB Output is correct
99 Correct 36 ms 3672 KB Output is correct
100 Correct 37 ms 3452 KB Output is correct
101 Correct 38 ms 3672 KB Output is correct
102 Correct 38 ms 3416 KB Output is correct
103 Correct 37 ms 3416 KB Output is correct
104 Correct 38 ms 3420 KB Output is correct
105 Correct 36 ms 3420 KB Output is correct