답안 #222190

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
222190 2020-04-12T09:58:45 Z kartel Akvizna (COCI19_akvizna) C++14
65 / 130
393 ms 7532 KB
#include <bits/stdc++.h>
#define in(x) freopen(x,"r",stdin)
#define out(x) freopen(x,"w",stdout)
#define F first
#define S second
#define pb push_back
#define M ll(998244353)
#define inf ll(2e9+7)
#define N ll(200500)
#define sz(x) x.size()
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
#define el '\n'
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> os;

ld f[N], b[N];
ll n, m, i, j, kol, sz, num[N], pr, K;
ld cht[N], k[N];

void AddInCHT(int i)
{
    ld x;
    while (1)
    {
        pr = num[sz];

        x = (b[pr] - b[i]) / (k[i] - k[pr]);
//        cerr << x << el;

        if (x - cht[sz] > 1e-18) break;

        sz--;
    }

    sz++;

    cht[sz] = x;
    num[sz] = i;
}

int ch(ld X)
{
    sz = 1;

    cht[sz] = -1e18;

    num[sz] = n;

    b[n] = 0;
    f[n] = 0;
    k[n] = 1.0 / ld(n);

    for (i = n - 1; i >= 0; i--)
        {
            int l = 1;
            int r = sz;

            while (l < r)
            {
                int md = (l + r + 1) >> 1;
                ld x = cht[md];

                if (x + ld(i) < 1e-18) l = md;
                                  else r = md - 1;
            }

            K = num[l];

            f[i] = f[K] + 1;

            b[i] = b[K] + 1 - ld(i) * k[K] + X;

            k[i] = ld(1) / ld(i);

            AddInCHT(i);
        }

    return f[0];
}

int main()
{
//    in("input.txt");
//    out("output.txt");

    ios_base::sync_with_stdio(false);
    iostream::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;

    ld l = 0;
    ld r = 1e12;

    while (r - l > 1e-9)
    {
        ld md = (l + r) * 0.5;

        if (ch(-md) > m) l = md + 1e-9;
                   else r = md;

    }

    ch(-l);

    cout << setprecision(9) << fixed << b[0] + l * ld(m);
}

# 결과 실행 시간 메모리 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 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 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 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 548 KB Output is correct
2 Correct 19 ms 512 KB Output is correct
3 Correct 13 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 640 KB Output is correct
2 Correct 15 ms 640 KB Output is correct
3 Correct 14 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 608 KB Output is correct
2 Correct 13 ms 512 KB Output is correct
3 Correct 19 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 512 KB Output is correct
2 Correct 15 ms 640 KB Output is correct
3 Correct 19 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 640 KB Output is correct
2 Correct 13 ms 512 KB Output is correct
3 Correct 14 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 512 KB Output is correct
2 Correct 14 ms 640 KB Output is correct
3 Correct 15 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 640 KB Output is correct
2 Correct 14 ms 640 KB Output is correct
3 Correct 15 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 512 KB Output is correct
2 Correct 15 ms 512 KB Output is correct
3 Correct 14 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 512 KB Output is correct
2 Correct 13 ms 512 KB Output is correct
3 Correct 13 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 343 ms 6928 KB Output is correct
2 Incorrect 367 ms 7008 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 341 ms 7012 KB Output is correct
2 Incorrect 363 ms 7180 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 331 ms 6880 KB Output is correct
2 Incorrect 393 ms 7504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 341 ms 7160 KB Output is correct
2 Incorrect 367 ms 7308 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 328 ms 6904 KB Output is correct
2 Incorrect 356 ms 7360 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 374 ms 7392 KB Output is correct
2 Correct 340 ms 7192 KB Output is correct
3 Incorrect 342 ms 7032 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 339 ms 7320 KB Output is correct
2 Incorrect 326 ms 6912 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 325 ms 6904 KB Output is correct
2 Incorrect 342 ms 7416 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 336 ms 7288 KB Output is correct
2 Correct 352 ms 7240 KB Output is correct
3 Incorrect 351 ms 7392 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 365 ms 7416 KB Output is correct
2 Incorrect 344 ms 7052 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 358 ms 7508 KB Output is correct
2 Correct 352 ms 7416 KB Output is correct
3 Incorrect 347 ms 7532 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 345 ms 7416 KB Output is correct
2 Incorrect 349 ms 7416 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 357 ms 7416 KB Output is correct
2 Incorrect 347 ms 7420 KB Output isn't correct
3 Halted 0 ms 0 KB -