답안 #335400

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
335400 2020-12-12T12:32:52 Z lauran Discharging (NOI20_discharging) C++14
47 / 100
1000 ms 9884 KB
#include <bits/stdc++.h>
using namespace std;

const int NMAX = 1e6 + 5;
const long long INF = 1e17;

int n;
int T[NMAX];
long long dp[NMAX];

bool sub3() {
    for (int i = 1; i < n; i++)
        if (T[i] > T[i + 1])
            return 0;
    return 1;
}

bool sub4() {
    for (int i = 1; i < n; i++)
        if (T[i] < T[i + 1])
            return 0;
    return 1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> T[i];

    if (sub4()) {
        long long ans = 0, maxim = 0;
        for (int i = 1; i <= n; i++) {
            maxim = max(maxim, (long long)T[i]);
            ans += maxim;
        }
        cout << ans;
        return 0;
    }

    dp[n] = T[n];

    for (int i = n - 1; i >= 1; i--) {
        int maxT = T[i];
        dp[i] = INF;
        for (int j = i; j <= n; j++) {
            maxT = max(maxT, T[j]);

            dp[i] = min(dp[i], (long long)maxT * (n - i + 1) + dp[j + 1]);
        }
    }

    cout << dp[1];

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 400 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 364 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 492 KB Output is correct
9 Correct 3 ms 364 KB Output is correct
10 Correct 3 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 364 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 492 KB Output is correct
9 Correct 3 ms 364 KB Output is correct
10 Correct 3 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Execution timed out 1088 ms 9884 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 115 ms 4588 KB Output is correct
2 Correct 112 ms 4204 KB Output is correct
3 Correct 128 ms 4204 KB Output is correct
4 Correct 115 ms 4332 KB Output is correct
5 Correct 115 ms 4384 KB Output is correct
6 Correct 114 ms 4224 KB Output is correct
7 Correct 112 ms 4204 KB Output is correct
8 Correct 113 ms 4348 KB Output is correct
9 Correct 138 ms 4460 KB Output is correct
10 Correct 113 ms 4204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 400 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 3 ms 364 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 492 KB Output is correct
23 Correct 3 ms 364 KB Output is correct
24 Correct 3 ms 364 KB Output is correct
25 Correct 3 ms 364 KB Output is correct
26 Correct 3 ms 364 KB Output is correct
27 Correct 3 ms 364 KB Output is correct
28 Correct 3 ms 364 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 3 ms 364 KB Output is correct
31 Correct 3 ms 364 KB Output is correct
32 Correct 4 ms 364 KB Output is correct
33 Correct 3 ms 364 KB Output is correct
34 Correct 3 ms 364 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 3 ms 364 KB Output is correct
37 Correct 3 ms 364 KB Output is correct
38 Correct 3 ms 364 KB Output is correct
39 Correct 3 ms 364 KB Output is correct
40 Correct 3 ms 364 KB Output is correct
41 Correct 3 ms 364 KB Output is correct
42 Correct 3 ms 364 KB Output is correct
43 Correct 3 ms 364 KB Output is correct
44 Correct 3 ms 364 KB Output is correct
45 Correct 3 ms 364 KB Output is correct
46 Correct 3 ms 364 KB Output is correct
47 Correct 3 ms 404 KB Output is correct
48 Correct 3 ms 500 KB Output is correct
49 Correct 3 ms 364 KB Output is correct
50 Correct 3 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 400 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 3 ms 364 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 492 KB Output is correct
23 Correct 3 ms 364 KB Output is correct
24 Correct 3 ms 364 KB Output is correct
25 Correct 3 ms 364 KB Output is correct
26 Correct 3 ms 364 KB Output is correct
27 Correct 3 ms 364 KB Output is correct
28 Correct 3 ms 364 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Execution timed out 1088 ms 9884 KB Time limit exceeded
31 Halted 0 ms 0 KB -