# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
309936 |
2020-10-05T03:40:41 Z |
phathnv |
Akvizna (COCI19_akvizna) |
C++11 |
|
1500 ms |
40828 KB |
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
typedef long long ll;
typedef pair<int, int> ii;
const int N = 3001;
struct line{
double a, b;
int cnt;
line(double _a = 0, double _b = 0, int _cnt = 0){
a = _a;
b = _b;
cnt = _cnt;
}
};
struct convexHull{
vector <line> d;
int ptr;
void reset(){
d.clear();
ptr = 0;
}
double calcY(const line &l, ll x){
return l.a * x + l.b;
}
bool bad(const line &l1, const line &l2, const line &l3){
return (l2.a - l3.a) * (l2.b - l1.b) >= (l1.a - l2.a) * (l3.b - l2.b);
}
void add(const line &newLine){
while (d.size() > 1){
if (bad(d[d.size() - 2], d[d.size() - 1], newLine))
d.pop_back();
else
break;
}
d.push_back(newLine);
}
double getMax(double x){
assert(!d.empty());
ptr = min(ptr, (int) d.size() - 1);
while (ptr < (int) d.size() - 1)
if (calcY(d[ptr], x) <= calcY(d[ptr + 1], x))
ptr++;
else
break;
return calcY(d[ptr], x);
}
int getCnt(double x){
assert(!d.empty());
ptr = min(ptr, (int) d.size() - 1);
while (ptr < (int) d.size() - 1)
if (calcY(d[ptr], x) <= calcY(d[ptr + 1], x))
ptr++;
else
break;
return d[ptr].cnt;
}
} cvh;
int n, k;
double dp[N][N];
void readInput(){
cin >> n >> k;
}
void solve(){
dp[1][0] = 0;
for(int j = 1; j <= n; j++)
dp[1][j] = 1;
for(int i = 2; i <= k; i++){
cvh.reset();
for(int j = 1; j <= n; j++){
cvh.add(line(dp[i - 1][j - 1], -(j - 1)));
dp[i][j] = cvh.getMax(j) / j + 1;
}
}
cout << dp[k][n];
}
int main(){
readInput();
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
10240 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
13312 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
10744 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
13688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
9336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
9848 KB |
Output is correct |
2 |
Incorrect |
119 ms |
40828 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
8568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
8704 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
12280 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1596 ms |
22380 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1585 ms |
21736 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1549 ms |
21736 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1548 ms |
20860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1588 ms |
21752 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1590 ms |
20348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1585 ms |
21068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1564 ms |
21752 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1585 ms |
20784 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1592 ms |
20844 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1593 ms |
20840 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1587 ms |
20532 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1598 ms |
20956 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |