Submission #222124

# Submission time Handle Problem Language Result Execution time Memory
222124 2020-04-12T07:08:31 Z NONAME Akvizna (COCI19_akvizna) C++17
20 / 130
1500 ms 32444 KB
#include <bits/stdc++.h>
#include <time.h>
//#include <random>
#define sz(x) int(x.size())
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define N 100500
#define oo ll(1e16)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define ft first
#define sd second
#define pb push_back
#define ppb pop_back
#define el '\n'
#define elf endl
#define base ll(1e9 + 7)
#define re return
#define nins 4294967295
using namespace std;
typedef long long ll;
typedef long double ld;

//mt19937 rnd(0);

int n, k;
ld f[1000][1000];

void solve() {
    cin >> n >> k;

    for (int i = 0; i <= k; i++)
    for (int j = 1; j <= n; j++)
        f[i][j] = -1;

    f[0][n] = 0;

    for (int kk = 0; kk < k; kk++)
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= i; j++) {
        if (f[kk][i] == -1)
            continue;

        f[kk + 1][i - j] = max(f[kk + 1][i - j], f[kk][i] + ld(j) / ld(i));
    }

    cout.precision(8); cout << fixed;

    cout << f[k][0];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef _LOCAL
        in("input.txt");

        int t = 1;
//        cin >> t;
        for (int i = 1; i <= t; i++) {
            cout << "Test #" << i << elf;

            clock_t start_time = clock();

            solve();

            cerr.precision(4); cerr << fixed;
            cerr << elf;
            cerr << "Time :: " << ld(clock() - start_time) / CLOCKS_PER_SEC << elf;

            cout << elf;
        }
    #else
        int t = 1;
//        cin >> t;

        while (t--) {
            solve();
            cout << el;
        }
    #endif
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 6 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 8 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 640 KB Output is correct
3 Correct 6 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 11 ms 640 KB Output is correct
3 Correct 6 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1568 ms 6912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1588 ms 8960 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1566 ms 7296 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1589 ms 9216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1583 ms 6272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1591 ms 6656 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1588 ms 5760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1594 ms 5888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1587 ms 8320 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 206 ms 32248 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 226 ms 32248 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 211 ms 32248 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 208 ms 32248 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 207 ms 32444 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 211 ms 32120 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 211 ms 32248 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 228 ms 32252 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 216 ms 32112 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 213 ms 32120 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 224 ms 32120 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 224 ms 32196 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 232 ms 32376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -