# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
989280 | AdamGS | Mountains (IOI17_mountains) | C++17 | 1 ms | 4444 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "mountains.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=2e3+7;
pair<int,int>ma1[LIM][LIM], ma2[LIM][LIM];
ll T[LIM];
int dp[LIM][LIM], odw[LIM][LIM], n;
int ilo(int a, int b, int c) {
pair<ll,ll>x={b-a, T[b]-T[a]}, y={c-a, T[c]-T[a]};
return x.st*y.nd-x.nd*y.st;
}
int solve(int l, int r) {
if(l>r) return 0;
if(odw[l][r]) return dp[l][r];
odw[l][r]=1;
if(ma1[l][r].nd!=-ma2[l][r].nd) {
dp[l][r]=max(solve(l, -ma2[l][r].nd-1)+solve(-ma2[l][r].nd+1, r), solve(l, ma1[l][r].nd-1)+solve(ma1[l][r].nd+1, r));
return dp[l][r];
}
int x=ma1[l][r].nd;
dp[l][r]=solve(l, x-1)+solve(x+1, r);
int sum=1, lst=x+1;
for(int i=x+2; i<=r; ++i) {
if(ilo(x, lst, i)>=0) {
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |