답안 #222157

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
222157 2020-04-12T09:03:36 Z NONAME Akvizna (COCI19_akvizna) C++17
65 / 130
1500 ms 3456 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[2][N];

void solve(int cr, int l, int r, int opl, int opr) {
    if (l > r)
        return;

    int md = (l + r) >> 1;

    int op = -1;

    for (int i = opl; i <= min(md, opr); i++) {
        if (f[1 ^ cr][i] == -1)
            continue;

        if (f[cr ^ 1][i] + ld(md - i) / ld(md) > f[cr][md]) {
            f[cr][md] = f[cr ^ 1][i] + ld(md - i) / ld(md);
            op = i;
        }
    }

    solve(cr, l, md - 1, opl, op);
    solve(cr, md + 1, r, op, opr);
}

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

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

    for (int i = 2; i <= k; i++) {
        for (int j = 0; j <= n; j++)
            f[i & 1][j] = -1;
        solve(i & 1, 1, n, 1, n);
    }

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

    cout << f[k & 1][n];
}

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
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 384 KB Output is correct
2 Correct 414 ms 632 KB Output is correct
3 Correct 459 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 155 ms 472 KB Output is correct
2 Correct 331 ms 432 KB Output is correct
3 Correct 552 ms 520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 384 KB Output is correct
2 Correct 214 ms 512 KB Output is correct
3 Correct 487 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 140 ms 512 KB Output is correct
2 Correct 346 ms 496 KB Output is correct
3 Correct 536 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 94 ms 384 KB Output is correct
2 Correct 297 ms 492 KB Output is correct
3 Correct 459 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 384 KB Output is correct
2 Correct 413 ms 384 KB Output is correct
3 Correct 568 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 384 KB Output is correct
2 Correct 428 ms 504 KB Output is correct
3 Correct 603 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 101 ms 504 KB Output is correct
2 Correct 320 ms 504 KB Output is correct
3 Correct 515 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 384 KB Output is correct
2 Correct 357 ms 384 KB Output is correct
3 Correct 544 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1594 ms 3200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1595 ms 3200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1589 ms 3200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1589 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1593 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1585 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1576 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1586 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1589 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1592 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1587 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1584 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1596 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -