답안 #879948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879948 2023-11-28T11:48:29 Z frostray8653 Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
232 ms 5080 KB
#include <bits/stdc++.h>
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
using pii = pair<int, int>;

const int N = 505;
const int INF = 1e15;
const double dINF = 1e15;
pii a[N];

signed main() {
    IO;
    
    int n, tar;
    cin >> n >> tar;
    FOR(i, 1, n) {
        cin >> a[i].first >> a[i].second;
        if (a[i].second == -1)
            a[i].second = INF;
    }
    sort(a + 1, a + n + 1, [&](pii p, pii q) {
        if (p.second != q.second)
            return p.second < q.second;
        return p.first < q.first;
    });
    vector<vector<double>> dp(n + 1, vector<double>(n + 1, dINF));
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        vector<vector<double>> ndp(n + 1, vector<double>(n + 1, dINF));
        for (int j = 0; j < i; j++) {
            for (int k = 0; k <= j; k++) {
                if (dp[j][k] < dINF) {
                    ndp[j][k] = min(ndp[j][k], dp[j][k]);
                    if (a[i].second < INF)
                        ndp[j + 1][k + 1] = min(ndp[j + 1][k + 1], dp[j][k] + (double)a[i].second / (k + 1));
                    ndp[j + 1][k] = min(ndp[j + 1][k], dp[j][k] + (double)a[i].first / (k + 1));
                }
            }
        }
        swap(dp, ndp);
    }
    double ans = dINF;
    for (int k = 0; k <= n; k++)
        ans = min(ans, dp[tar][k]);
    cout << fixed << setprecision(10) << ans << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 167 ms 4588 KB Output is correct
6 Correct 170 ms 4560 KB Output is correct
7 Correct 173 ms 4592 KB Output is correct
8 Correct 174 ms 4880 KB Output is correct
9 Correct 171 ms 4560 KB Output is correct
10 Correct 168 ms 4428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 167 ms 4588 KB Output is correct
6 Correct 170 ms 4560 KB Output is correct
7 Correct 173 ms 4592 KB Output is correct
8 Correct 174 ms 4880 KB Output is correct
9 Correct 171 ms 4560 KB Output is correct
10 Correct 168 ms 4428 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 232 ms 5080 KB Output is correct
13 Correct 191 ms 4572 KB Output is correct
14 Correct 177 ms 4640 KB Output is correct
15 Correct 222 ms 4688 KB Output is correct
16 Correct 188 ms 4676 KB Output is correct
17 Correct 176 ms 4628 KB Output is correct
18 Correct 221 ms 4968 KB Output is correct
19 Correct 195 ms 4604 KB Output is correct
20 Correct 179 ms 4580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 464 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 464 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 464 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 213 ms 4796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 167 ms 4588 KB Output is correct
6 Correct 170 ms 4560 KB Output is correct
7 Correct 173 ms 4592 KB Output is correct
8 Correct 174 ms 4880 KB Output is correct
9 Correct 171 ms 4560 KB Output is correct
10 Correct 168 ms 4428 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 232 ms 5080 KB Output is correct
13 Correct 191 ms 4572 KB Output is correct
14 Correct 177 ms 4640 KB Output is correct
15 Correct 222 ms 4688 KB Output is correct
16 Correct 188 ms 4676 KB Output is correct
17 Correct 176 ms 4628 KB Output is correct
18 Correct 221 ms 4968 KB Output is correct
19 Correct 195 ms 4604 KB Output is correct
20 Correct 179 ms 4580 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 464 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Incorrect 0 ms 348 KB Output isn't correct
30 Halted 0 ms 0 KB -