# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
282602 |
2020-08-24T15:29:43 Z |
cgiosy |
Akvizna (COCI19_akvizna) |
C++17 |
|
1028 ms |
2536 KB |
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using flt=double;
int main() {
ios::sync_with_stdio(0);cin.tie(0);
int N, K;
cin>>N>>K;
flt l=0, r=2;
vector<int> C(N+1), P(N+1);
cout<<fixed<<setprecision(9);
auto f=[&](flt m) {
vector<double> D(N+1);
vector<int> T(1<<32-__builtin_clz(N));
auto f=[&](int j, int i) {
return D[j]+flt(i-j)/i;
};
auto cmp=[&](int i, int j, int x) {
return f(i, x)>f(j, x);
};
auto add=[&](int a) {
int s=1, e=N, i=1;
while(i) {
int m=s+e>>1, &b=T[i];
if(cmp(a, b, m)) swap(a, b);
if(cmp(a, b, s)) e=m-1, i=i*2;
else if(cmp(a, b, e)) s=m+1, i=i*2+1;
else break;
}
};
auto get=[&](int x) {
int s=1, e=N, i=1, a=0;
while(i) {
int m=s+e>>1, b=T[i];
if(cmp(b, a, x)) a=b;
if(x<m) e=m-1, i=i*2;
else if(x>m) s=m+1, i=i*2+1;
else break;
}
return a;
};
D[0]=0;
for(int i=1; i<=N; i++) {
add(i-1);
int p=get(i);
P[i]=p;
C[i]=C[p]+1;
D[i]=f(p, i)-m;
}
return make_pair(C[N], D[N]+K*m);
};
while(r-l>1e-9) {
flt m=(l+r)/2;
auto[k,x]=f(m);
if(k<K) r=m;
else if(k>K) l=m;
else { l=r=m; break; }
}
cout<<fixed<<setprecision(9)<<f((l+r)/2).second;
}
Compilation message
akvizna.cpp: In lambda function:
akvizna.cpp:15:22: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
15 | vector<int> T(1<<32-__builtin_clz(N));
| ~~^~~~~~~~~~~~~~~~~
akvizna.cpp: In lambda function:
akvizna.cpp:25:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
25 | int m=s+e>>1, &b=T[i];
| ~^~
akvizna.cpp: In lambda function:
akvizna.cpp:35:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
35 | int m=s+e>>1, b=T[i];
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
384 KB |
Output is correct |
2 |
Correct |
23 ms |
384 KB |
Output is correct |
3 |
Correct |
22 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
384 KB |
Output is correct |
2 |
Correct |
17 ms |
384 KB |
Output is correct |
3 |
Correct |
21 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
384 KB |
Output is correct |
2 |
Correct |
17 ms |
384 KB |
Output is correct |
3 |
Correct |
21 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
384 KB |
Output is correct |
2 |
Correct |
21 ms |
384 KB |
Output is correct |
3 |
Correct |
21 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
384 KB |
Output is correct |
2 |
Correct |
21 ms |
384 KB |
Output is correct |
3 |
Correct |
21 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
384 KB |
Output is correct |
2 |
Correct |
22 ms |
384 KB |
Output is correct |
3 |
Correct |
23 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
384 KB |
Output is correct |
2 |
Correct |
20 ms |
444 KB |
Output is correct |
3 |
Correct |
22 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
384 KB |
Output is correct |
2 |
Correct |
17 ms |
384 KB |
Output is correct |
3 |
Correct |
21 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
384 KB |
Output is correct |
2 |
Correct |
20 ms |
384 KB |
Output is correct |
3 |
Correct |
21 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
931 ms |
2460 KB |
Output is correct |
2 |
Correct |
937 ms |
2408 KB |
Output is correct |
3 |
Incorrect |
905 ms |
2328 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
936 ms |
2432 KB |
Output is correct |
2 |
Incorrect |
965 ms |
2440 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
951 ms |
2360 KB |
Output is correct |
2 |
Incorrect |
984 ms |
2532 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
965 ms |
2436 KB |
Output is correct |
2 |
Correct |
973 ms |
2440 KB |
Output is correct |
3 |
Incorrect |
930 ms |
2380 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
923 ms |
2372 KB |
Output is correct |
2 |
Incorrect |
970 ms |
2536 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
989 ms |
2532 KB |
Output is correct |
2 |
Incorrect |
940 ms |
2440 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
982 ms |
2436 KB |
Output is correct |
2 |
Incorrect |
903 ms |
2304 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
943 ms |
2336 KB |
Output is correct |
2 |
Incorrect |
986 ms |
2432 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
990 ms |
2452 KB |
Output is correct |
2 |
Correct |
945 ms |
2436 KB |
Output is correct |
3 |
Incorrect |
975 ms |
2468 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
974 ms |
2456 KB |
Output is correct |
2 |
Incorrect |
933 ms |
2444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
991 ms |
2472 KB |
Output is correct |
2 |
Incorrect |
981 ms |
2536 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1028 ms |
2472 KB |
Output is correct |
2 |
Correct |
986 ms |
2532 KB |
Output is correct |
3 |
Incorrect |
994 ms |
2532 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
995 ms |
2528 KB |
Output is correct |
2 |
Incorrect |
996 ms |
2432 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |