답안 #172759

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
172759 2020-01-02T14:27:04 Z gs18103 Mountains (IOI17_mountains) C++14
0 / 100
2 ms 504 KB
#include "mountains.h"
#include <bits/stdc++.h>
#define eb emplace_back
#define em emplace
#define fi first
#define se second
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int MAX = 2020;
const int INF = 1<<30;
const ll LINF = 1LL<<62;

ll dp[MAX][MAX], h[MAX];

int f(int s, int e) {
    if(s > e) return 0;
    if(dp[s][e] != 0) return dp[s][e];
    dp[s][e] = 1;
    pll high = make_pair(h[s+1] - h[s], 1);
    int idx = s + 1;
    for(int i = s + 2; i <= e; i++) {
        if((h[i] - h[s]) * high.se >= high.fi * (i - s)) {
            dp[s][e] += f(idx+1, i-1);
            idx = i;
            high = make_pair(h[i] - h[s], i - s);
        }
    }
    dp[s][e] += f(idx+1, e);
    return dp[s][e];
}

int maximum_deevs(vector <int> y) {
    ios::sync_with_stdio(false); cin.tie(0);

    int n = y.size();
    for(int i = 1; i <= n; i++) {
        h[i] = y[i-1];
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            ans = max(ans, f(i, j));
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 504 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 504 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 504 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 504 KB Output isn't correct
7 Halted 0 ms 0 KB -