# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
222608 |
2020-04-13T12:12:38 Z |
Vimmer |
Akvizna (COCI19_akvizna) |
C++14 |
|
1500 ms |
2424 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;
int kol[N], n, k;
ld dp[N];
//vector <int> cxt;
//
//vector <ld> otr;
//
//ld cross(pair <ld, ld> x, pair <ld, ld> y) {return ld(ld(y.S - x.S) / ld(x.F - y.F));}
//
//void add(int i)
//{
// while (sz(cxt) > 1)
// {
// int j = cxt[sz(cxt) - 2];
//
// ld crs = cross({ld(1) / ld(i), dp[i]}, {ld(1) / ld(j), dp[j]});
//
// if (otr.back() > crs) break;
//
// otr.pop_back();
//
// cxt.pop_back();
// }
//
// int j = cxt.back();
//
// otr.pb(cross({ld(1) / ld(i), dp[i]}, {ld(1) / ld(j), dp[j]}));
//
// cxt.pb(i);
//}
ld clc(int x, int y, ld cost) {return dp[y] + ld(y - x) / ld(y) + cost;}
void calc(ld cost)
{
dp[n] = 0;
kol[n] = 0;
// cxt.clear();
//
// otr.clear();
//
// cxt.pb(n);
for (int i = n - 1; i >= 0; i--)
{
// int l = 0, r = sz(cxt) - 1;
//
// while (l < r)
// {
// int md = (r + l) >> 1;
//
// if (ld(i) > otr[md]) r = md; else l = md + 1;
// }
//
// int j = cxt[l];
//
// kol[i] = kol[j] + 1;
//
// dp[i] = dp[j] + cost + 1 - ld(i) * (ld(1) / ld(j));
//
// add(i);
int l = i + 1, r = n;
while (r - l > 10)
{
int mdl = l + (r - l) / 3;
int mdr = r - (r - l) / 3;
if (clc(i, mdl, cost) > clc(i, mdr, cost)) r = mdr; else l = mdl;
}
dp[i] = 0;
for (int j = l; j <= r; j++)
if (dp[i] < clc(i, j, cost)) {dp[i] = clc(i, j, cost); kol[i] = kol[j] + 1;}
}
}
int main()
{
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> k;
cout << setprecision(9) << fixed;
ld l = -1e9, r = 0;
while (r - l > 0.0000000000001)
{
ld md = (r + l) / 2.0;
calc(md);
if (kol[0] <= k) l = md; else r = md;
}
calc(l);
cout << ld(dp[0] - l * ld(kol[0]));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
71 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
76 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
74 ms |
480 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
75 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
73 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
68 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
77 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
72 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
77 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1572 ms |
2196 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1592 ms |
2112 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1583 ms |
2384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1587 ms |
2248 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1587 ms |
2168 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1587 ms |
2296 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1596 ms |
2168 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1593 ms |
2168 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1591 ms |
2296 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1594 ms |
2424 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1594 ms |
2208 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1585 ms |
2296 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1590 ms |
2296 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |