# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
222155 |
2020-04-12T08:36:19 Z |
kartel |
Akvizna (COCI19_akvizna) |
C++14 |
|
525 ms |
225144 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[3001][3001];
ll n, m, i, j, kol, sz, num[N], pr, K;
ld cht[N], b[3001][3001], k[3001][3001];
void AddInCHT(int i, int j)
{
ld x;
while (1)
{
pr = num[sz];
x = (b[pr][j] - b[i][j]) / (k[i][j] - k[pr][j]);
// cerr << x << el;
if (x - cht[sz] > 1e-9) break;
sz--;
}
sz++;
cht[sz] = x;
num[sz] = i;
}
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;
f[n][0] = 0;
for (i = 1; i < n; i++) b[i][0] = -1e18, k[i][0] = 0;
for (i = 1; i <= m; i++) f[n][i] = 0, k[n][i] = 0, b[n][i] = -1e18;
k[n][0] = ld(1) / ld(n);
b[n][0] = 0;
for (j = 1; j <= m; j++)
{
sz = 1;
cht[sz] = -1e18;
num[sz] = n - j + 1;
for (i = n - j; 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-9) l = md;
else r = md - 1;
}
K = num[l];
f[i][j] = b[K][j - 1] + 1 - ld(i) * k[K][j - 1];
k[i][j] = ld(1) / ld(i);
b[i][j] = f[i][j];
if (k[i][j - 1] != 0) AddInCHT(i, j - 1);
}
}
cout << setprecision(9) << fixed << f[0][m];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1536 KB |
Output is correct |
2 |
Correct |
5 ms |
1408 KB |
Output is correct |
3 |
Correct |
5 ms |
1664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1536 KB |
Output is correct |
2 |
Correct |
5 ms |
1536 KB |
Output is correct |
3 |
Correct |
5 ms |
1664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1408 KB |
Output is correct |
2 |
Correct |
5 ms |
1664 KB |
Output is correct |
3 |
Correct |
5 ms |
1408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1280 KB |
Output is correct |
2 |
Correct |
5 ms |
1792 KB |
Output is correct |
3 |
Correct |
5 ms |
1408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
161 ms |
82368 KB |
Output is correct |
2 |
Correct |
444 ms |
196932 KB |
Output is correct |
3 |
Correct |
477 ms |
201400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
201 ms |
101880 KB |
Output is correct |
2 |
Correct |
437 ms |
181624 KB |
Output is correct |
3 |
Correct |
477 ms |
211704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
174 ms |
88928 KB |
Output is correct |
2 |
Correct |
294 ms |
131192 KB |
Output is correct |
3 |
Correct |
426 ms |
187704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
209 ms |
102136 KB |
Output is correct |
2 |
Correct |
408 ms |
174584 KB |
Output is correct |
3 |
Correct |
473 ms |
201308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
152 ms |
80504 KB |
Output is correct |
2 |
Correct |
398 ms |
168952 KB |
Output is correct |
3 |
Correct |
423 ms |
188152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
139 ms |
75896 KB |
Output is correct |
2 |
Correct |
479 ms |
207352 KB |
Output is correct |
3 |
Correct |
525 ms |
225144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
140 ms |
80352 KB |
Output is correct |
2 |
Correct |
483 ms |
207096 KB |
Output is correct |
3 |
Correct |
514 ms |
223096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
137 ms |
76152 KB |
Output is correct |
2 |
Correct |
389 ms |
170872 KB |
Output is correct |
3 |
Correct |
488 ms |
209272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
198 ms |
99680 KB |
Output is correct |
2 |
Correct |
418 ms |
179064 KB |
Output is correct |
3 |
Correct |
494 ms |
212472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
22 ms |
512 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 |
22 ms |
512 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 |
23 ms |
512 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 |
23 ms |
512 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 |
22 ms |
448 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 |
23 ms |
512 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 |
32 ms |
528 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 |
27 ms |
640 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 |
23 ms |
512 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 |
26 ms |
512 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 |
24 ms |
512 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 |
23 ms |
512 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 |
22 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |