Submission #222188

# Submission time Handle Problem Language Result Execution time Memory
222188 2020-04-12T09:52:52 Z Vimmer Akvizna (COCI19_akvizna) C++14
65 / 130
1500 ms 3456 KB
#include <bits/stdc++.h>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 100005
#define MOD ll(998244353)

using namespace std;

typedef long long ll;

typedef long double ld;


ld last[N], now[N];

vector <pair <ld, ld> > otr;

vector <int> conv;

ld cross(pair <ld, ld> a, pair <ld, ld> b) {return ld(ld(b.S - a.S) / ld(a.F - b.F));}

ld calc(int a, int b)
{
    ld x = a;

    ld y = b;

    ld sm = 0;

    if (y != 0) sm = x / y;

    return last[b] + sm;
}

int main()
{

    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, k;

    cin >> n >> k;

    cout << setprecision(9) << fixed;

    if (k >= n)
    {
        ld ans = 0;

        for (int i = 1; i <= n; i++) ans += ld(i) / ld(n);

        cout << ans << endl;

        exit(0);
    }

    for (int i = 0; i <= n; i++) {last[i] = 0; now[i] = 0;}

    for (int j = 0; j < k; j++)
    {
        for (int i = 0; i <= n; i++)
        {
            int l = i, r = n;

            while (l + 10 < r)
            {
                int mdl = l + (r - l) / 3;

                int mdr = r - (r - l) / 3;

                if (calc(mdl - i, mdl) > calc(mdr - i, mdr)) r = mdr; else l = mdl;
            }

            for (int j = l; j <= r; j++) now[i] = max(now[i], calc(j - i, j));

        }

        for (int i = 0; i <= n; i++) {last[i] = now[i]; now[i] = 0;}

    }

    cout << last[0];
}
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 179 ms 512 KB Output is correct
2 Correct 841 ms 520 KB Output is correct
3 Correct 1043 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 318 ms 504 KB Output is correct
2 Correct 722 ms 484 KB Output is correct
3 Correct 1134 ms 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 201 ms 384 KB Output is correct
2 Correct 459 ms 468 KB Output is correct
3 Correct 995 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 263 ms 384 KB Output is correct
2 Correct 596 ms 384 KB Output is correct
3 Correct 1153 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 187 ms 384 KB Output is correct
2 Correct 624 ms 484 KB Output is correct
3 Correct 998 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 174 ms 384 KB Output is correct
2 Correct 902 ms 520 KB Output is correct
3 Correct 1194 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 166 ms 384 KB Output is correct
2 Correct 822 ms 384 KB Output is correct
3 Correct 1288 ms 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 155 ms 512 KB Output is correct
2 Correct 667 ms 484 KB Output is correct
3 Correct 1050 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 238 ms 384 KB Output is correct
2 Correct 742 ms 504 KB Output is correct
3 Correct 1165 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1590 ms 3200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1586 ms 3200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1591 ms 3200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1593 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1594 ms 3200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1592 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1597 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1591 ms 3200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1595 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1595 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1595 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1594 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1597 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -