# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
989280 | AdamGS | Mountains (IOI17_mountains) | C++17 | 1 ms | 4444 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |