# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
74430 |
2018-09-01T09:46:10 Z |
mjt |
Mountains (IOI17_mountains) |
C++11 |
|
227 ms |
263168 KB |
#include"mountains.h"
#include<bits/stdc++.h>
using namespace std;
const int N = 2010;
int y[N];
int f[N][N];
bool Judge(int a,int b,int c) { // a see c ?
// ((y[a] - y[b]) / (a - b)) > ((y[a] - y[c]) / (a - c));
return 1ll * (y[a] - y[b]) * (a - c) >= 1ll * (y[a] - y[c]) * (a - b);
}
int solve(int l,int r) {
if (f[l][r]) return f[l][r];
if (l > r) return 0;
if (l == r) return 1;
int pos = -1, mx = -1;
for (int i=l; i<=r; ++i) if (y[i] > mx) pos = i, mx = y[i];
int ans1 = solve(l, pos - 1) + solve(pos + 1, r);
int ans2 = 0;
for (int i=pos-1,j; i>=l; i=j) {
for (j=i-1; j>=l; --j) {
if (Judge(j, i, pos)) {
if (j == l) ans2 += solve(l, i - 1);
continue;
}
if (j + 1 <= i - 1) ans2 += solve(j + 1, i - 1);
break;
}
}
for (int i=pos-1,j; i<=r; i=j) {
for (j=i+1; j<=r; ++j) {
if (Judge(pos, i, j)) {
if (j == r) ans2 += solve(i + 1, r);
continue;
}
if (i + 1 <= j - 1) ans2 += solve(i + 1, j - 1);
break;
}
}
return f[l][r] = max(ans1, ans2);
}
int maximum_deevs(vector<int> A) {
int n = A.size();
for (int i=1; i<=n; ++i) y[i] = A[i - 1];
return solve(1, n);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
472 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Runtime error |
227 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
472 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Runtime error |
227 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
472 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Runtime error |
227 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
472 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Runtime error |
227 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Halted |
0 ms |
0 KB |
- |