Submission #698554

# Submission time Handle Problem Language Result Execution time Memory
698554 2023-02-13T18:59:37 Z Danilo21 Let's Win the Election (JOI22_ho_t3) C++14
10 / 100
1715 ms 8396 KB
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "YES" << en
#define no cout << "NO" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) (__builtin_popcountll(a))
#define bithigh(a) (63-__builtin_clzll(a))
#define lg bithigh
#define highpow(a) (1LL << (ll)lg(a))

using namespace std;

const ll LINF = 4e18;
const int mxN = 5e2+10, INF = 2e9;
int n, m;
array<int, 2> a[mxN];
ld dp[2][mxN][mxN];

ld Div(ld x, ld y){ return x/y; }

void Solve(){

    cin >> n >> m;
    for (int i = 1; i <= n; i++){
        cin >> a[i][1] >> a[i][0];
        if (!~a[i][0]) a[i][0] = INF;
    }
    sort(a+1, a+n+1);
    for (int i = 1; i <= n; i++){
        swap(a[i][0], a[i][1]);
        if (a[i][1] == INF) a[i][1] = -1;
    }
    for (int j = 0; j <= n; j++)
        for (int t = 0; t <= n; t++)
            dp[0][j][t] = INF;
    dp[0][0][0] = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= n; j++){
            for (int t = 0; t <= n; t++){
                dp[1][j][t] = dp[0][j][t];
                if (j) smin(dp[1][j][t], dp[0][j-1][t] + Div(a[i][0], t+1));
                if (~a[i][1] && j && t) smin(dp[1][j][t], dp[0][j-1][t-1] + Div(a[i][1], t));
            }
        }
        for (int j = 0; j <= n; j++)
            for (int t = 0; t <= n; t++)
                dp[0][j][t] = dp[1][j][t];
    }
    ld ans = INF;
    for (int i = 0; i <= m; i++)
        if (dp[0][m][i] != -1)
            smin(ans, dp[0][m][i]);
    cout << ans << en;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0); cerr.tie(0);
    cout << setprecision(12) << fixed;
    cerr << setprecision(12) << fixed;
    cerr << "Started!" << endl;

    int t = 1;
    //cin >> t;
    while (t--)
        Solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1322 ms 8324 KB Output is correct
6 Correct 1206 ms 8320 KB Output is correct
7 Correct 1094 ms 8396 KB Output is correct
8 Correct 1113 ms 8316 KB Output is correct
9 Correct 1129 ms 8328 KB Output is correct
10 Correct 1192 ms 8276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1322 ms 8324 KB Output is correct
6 Correct 1206 ms 8320 KB Output is correct
7 Correct 1094 ms 8396 KB Output is correct
8 Correct 1113 ms 8316 KB Output is correct
9 Correct 1129 ms 8328 KB Output is correct
10 Correct 1192 ms 8276 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1691 ms 8320 KB Output is correct
13 Correct 1474 ms 8316 KB Output is correct
14 Correct 1302 ms 8324 KB Output is correct
15 Correct 1712 ms 8316 KB Output is correct
16 Correct 1440 ms 8352 KB Output is correct
17 Correct 1227 ms 8316 KB Output is correct
18 Correct 1700 ms 8320 KB Output is correct
19 Correct 1460 ms 8320 KB Output is correct
20 Correct 1319 ms 8320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 284 KB Output is correct
9 Incorrect 1 ms 332 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 284 KB Output is correct
9 Incorrect 1 ms 332 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 284 KB Output is correct
9 Incorrect 1 ms 332 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1715 ms 8320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1322 ms 8324 KB Output is correct
6 Correct 1206 ms 8320 KB Output is correct
7 Correct 1094 ms 8396 KB Output is correct
8 Correct 1113 ms 8316 KB Output is correct
9 Correct 1129 ms 8328 KB Output is correct
10 Correct 1192 ms 8276 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1691 ms 8320 KB Output is correct
13 Correct 1474 ms 8316 KB Output is correct
14 Correct 1302 ms 8324 KB Output is correct
15 Correct 1712 ms 8316 KB Output is correct
16 Correct 1440 ms 8352 KB Output is correct
17 Correct 1227 ms 8316 KB Output is correct
18 Correct 1700 ms 8320 KB Output is correct
19 Correct 1460 ms 8320 KB Output is correct
20 Correct 1319 ms 8320 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 284 KB Output is correct
29 Incorrect 1 ms 332 KB Output isn't correct
30 Halted 0 ms 0 KB -