답안 #528940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528940 2022-02-21T19:19:44 Z tabr Mountains (IOI17_mountains) C++17
0 / 100
1 ms 316 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int maximum_deevs(vector<int> y) {
    int n = (int) y.size();
    vector<vector<int>> dp(n + 1, vector<int>(n + 1));
    for (int l = n - 1; l >= 0; l--) {
        for (int r = l + 1; r <= n; r++) {
            int pos = (int) (max_element(y.begin() + l, y.begin() + r) - y.begin());
            dp[l][r] = 1;
            int lst = pos;
            pair<int, int> a = make_pair(1, 0);
            for (int i = pos - 1; i >= l; i--) {
                auto b = make_pair(y[pos] - y[i], pos - i);
                if (1LL * a.first * b.second > 1LL * a.second * b.first) {
                    a = b;
                    dp[l][r] += dp[i + 1][lst];
                    lst = i;
                }
            }
            dp[l][r] += dp[l][lst];
            lst = pos;
            a = make_pair(1, 0);
            for (int i = pos + 1; i < r; i++) {
                auto b = make_pair(y[pos] - y[i], i - pos);
                if (1LL * a.first * b.second > 1LL * a.second * b.first) {
                    a = b;
                    dp[l][r] += dp[lst + 1][i];
                    lst = i;
                }
            }
            dp[l][r] += dp[lst + 1][r];
            dp[l][r] = max(dp[l][r], dp[l][pos] + dp[pos + 1][r]);
        }
    }
    return dp[0][n];
}

#ifdef tabr
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    return 0;
}
#endif
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 276 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 292 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Incorrect 1 ms 256 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 276 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 292 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Incorrect 1 ms 256 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 276 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 292 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Incorrect 1 ms 256 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 276 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 292 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Incorrect 1 ms 256 KB Output isn't correct
13 Halted 0 ms 0 KB -