답안 #988594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
988594 2024-05-25T08:44:30 Z _callmelucian Let's Win the Election (JOI22_ho_t3) C++14
100 / 100
144 ms 2640 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tt;

#define all(a) a.begin(), a.end()
#define filter(a) a.erase(unique(all(a)), a.end())

const double INF = 1e9;
double dp[505][505];

struct P {
    int norm, col;

    P() : norm(0), col(0) {}
    P (int a, int b) : norm(a), col(b) {}

    friend istream& operator >> (istream &inp, P &cur) {
        inp >> cur.norm >> cur.col;
        return inp;
    }

    bool operator < (const P &o) const {
        if (col == o.col || col == -1) return 0;
        if (o.col == -1) return 1;
        return col < o.col;
    }
} a[505];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, k; cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + 1 + n);

    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= k; j++)
            dp[i][j] = INF;

    double ans = INF;
    for (int cntNorm = 0; cntNorm <= k; cntNorm++) {
        int collab = k - cntNorm;
        dp[0][0] = 0;

        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= min(i, cntNorm); j++) {
                //dp[i][j] = dp[i - 1][j];
                if (j && dp[i - 1][j - 1] != INF)
                    dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + double(a[i].norm) / double(collab + 1));
                if (i - j <= collab && dp[i - 1][j] != INF && a[i].col != -1)
                    dp[i][j] = min(dp[i][j], dp[i - 1][j] + double(a[i].col) / double(i - j));
                if (i - j > collab)
                    dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            }
        }

        //cout << cntNorm << " " << dp[n][cntNorm] << "\n";
        ans = min(ans, dp[n][cntNorm]);

        for (int i = 1; i <= n; i++)
            for (int j = 0; j <= min(i, cntNorm); j++)
                dp[i][j] = INF;
    }

    cout << fixed << setprecision(9) << ans;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 2396 KB Output is correct
6 Correct 8 ms 2396 KB Output is correct
7 Correct 25 ms 2392 KB Output is correct
8 Correct 51 ms 2392 KB Output is correct
9 Correct 72 ms 2392 KB Output is correct
10 Correct 43 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 2396 KB Output is correct
6 Correct 8 ms 2396 KB Output is correct
7 Correct 25 ms 2392 KB Output is correct
8 Correct 51 ms 2392 KB Output is correct
9 Correct 72 ms 2392 KB Output is correct
10 Correct 43 ms 2396 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 17 ms 2404 KB Output is correct
13 Correct 17 ms 2392 KB Output is correct
14 Correct 16 ms 2392 KB Output is correct
15 Correct 73 ms 2396 KB Output is correct
16 Correct 72 ms 2392 KB Output is correct
17 Correct 57 ms 2392 KB Output is correct
18 Correct 139 ms 2428 KB Output is correct
19 Correct 137 ms 2396 KB Output is correct
20 Correct 91 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 472 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 348 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 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 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 592 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 472 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 348 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 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 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 592 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 1 ms 860 KB Output is correct
42 Correct 1 ms 600 KB Output is correct
43 Correct 1 ms 860 KB Output is correct
44 Correct 1 ms 860 KB Output is correct
45 Correct 1 ms 856 KB Output is correct
46 Correct 1 ms 860 KB Output is correct
47 Correct 2 ms 860 KB Output is correct
48 Correct 2 ms 860 KB Output is correct
49 Correct 2 ms 860 KB Output is correct
50 Correct 2 ms 856 KB Output is correct
51 Correct 2 ms 860 KB Output is correct
52 Correct 2 ms 860 KB Output is correct
53 Correct 1 ms 860 KB Output is correct
54 Correct 2 ms 860 KB Output is correct
55 Correct 1 ms 860 KB Output is correct
56 Correct 1 ms 860 KB Output is correct
57 Correct 1 ms 856 KB Output is correct
58 Correct 1 ms 856 KB Output is correct
59 Correct 1 ms 860 KB Output is correct
60 Correct 1 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 134 ms 2420 KB Output is correct
2 Correct 137 ms 2396 KB Output is correct
3 Correct 132 ms 2424 KB Output is correct
4 Correct 142 ms 2424 KB Output is correct
5 Correct 144 ms 2392 KB Output is correct
6 Correct 135 ms 2392 KB Output is correct
7 Correct 140 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 2396 KB Output is correct
6 Correct 8 ms 2396 KB Output is correct
7 Correct 25 ms 2392 KB Output is correct
8 Correct 51 ms 2392 KB Output is correct
9 Correct 72 ms 2392 KB Output is correct
10 Correct 43 ms 2396 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 17 ms 2404 KB Output is correct
13 Correct 17 ms 2392 KB Output is correct
14 Correct 16 ms 2392 KB Output is correct
15 Correct 73 ms 2396 KB Output is correct
16 Correct 72 ms 2392 KB Output is correct
17 Correct 57 ms 2392 KB Output is correct
18 Correct 139 ms 2428 KB Output is correct
19 Correct 137 ms 2396 KB Output is correct
20 Correct 91 ms 2396 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 472 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 348 KB Output is correct
42 Correct 1 ms 464 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 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 344 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 592 KB Output is correct
58 Correct 1 ms 344 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 1 ms 344 KB Output is correct
61 Correct 1 ms 860 KB Output is correct
62 Correct 1 ms 600 KB Output is correct
63 Correct 1 ms 860 KB Output is correct
64 Correct 1 ms 860 KB Output is correct
65 Correct 1 ms 856 KB Output is correct
66 Correct 1 ms 860 KB Output is correct
67 Correct 2 ms 860 KB Output is correct
68 Correct 2 ms 860 KB Output is correct
69 Correct 2 ms 860 KB Output is correct
70 Correct 2 ms 856 KB Output is correct
71 Correct 2 ms 860 KB Output is correct
72 Correct 2 ms 860 KB Output is correct
73 Correct 1 ms 860 KB Output is correct
74 Correct 2 ms 860 KB Output is correct
75 Correct 1 ms 860 KB Output is correct
76 Correct 1 ms 860 KB Output is correct
77 Correct 1 ms 856 KB Output is correct
78 Correct 1 ms 856 KB Output is correct
79 Correct 1 ms 860 KB Output is correct
80 Correct 1 ms 860 KB Output is correct
81 Correct 134 ms 2420 KB Output is correct
82 Correct 137 ms 2396 KB Output is correct
83 Correct 132 ms 2424 KB Output is correct
84 Correct 142 ms 2424 KB Output is correct
85 Correct 144 ms 2392 KB Output is correct
86 Correct 135 ms 2392 KB Output is correct
87 Correct 140 ms 2640 KB Output is correct
88 Correct 4 ms 2256 KB Output is correct
89 Correct 4 ms 2396 KB Output is correct
90 Correct 12 ms 2448 KB Output is correct
91 Correct 12 ms 2392 KB Output is correct
92 Correct 41 ms 2424 KB Output is correct
93 Correct 48 ms 2432 KB Output is correct
94 Correct 82 ms 2396 KB Output is correct
95 Correct 82 ms 2392 KB Output is correct
96 Correct 113 ms 2424 KB Output is correct
97 Correct 111 ms 2396 KB Output is correct
98 Correct 73 ms 2396 KB Output is correct
99 Correct 73 ms 2396 KB Output is correct
100 Correct 74 ms 2424 KB Output is correct
101 Correct 76 ms 2396 KB Output is correct
102 Correct 72 ms 2396 KB Output is correct
103 Correct 74 ms 2396 KB Output is correct
104 Correct 72 ms 2396 KB Output is correct
105 Correct 72 ms 2396 KB Output is correct