답안 #521588

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
521588 2022-02-02T13:46:40 Z pokmui9909 Feast (NOI19_feast) C++17
100 / 100
159 ms 15064 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define x first
#define y second
ll N, K;
ll A[300005];
pair<ll, ll> D[300005][2];
pair<ll, ll> f(ll lmb){
    for(int i = 1; i <= N; i++){
        D[i][0] = max(D[i - 1][0], make_pair(D[i - 1][1].x - lmb, D[i - 1][1].y - 1));
        D[i][1] = max(D[i - 1][0], D[i - 1][1]);
        D[i][1].x += A[i];
    }
    return max(D[N][0], make_pair(D[N][1].x - lmb, D[N][1].y - 1));
}
 
int main(){
    cin.tie(0) -> sync_with_stdio(false);
    
    cin >> N >> K;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
    }
    ll L = 0, R = 3e14 + 7;
    while(L <= R){
        ll m = (L + R) / 2;
        if(-f(m).y <= K) R = m - 1;
        else L = m + 1;
    }
    cout << f(L).x + L * K;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 14400 KB Output is correct
2 Correct 116 ms 14716 KB Output is correct
3 Correct 100 ms 14912 KB Output is correct
4 Correct 117 ms 14956 KB Output is correct
5 Correct 100 ms 14664 KB Output is correct
6 Correct 93 ms 14396 KB Output is correct
7 Correct 94 ms 14468 KB Output is correct
8 Correct 108 ms 14712 KB Output is correct
9 Correct 90 ms 14412 KB Output is correct
10 Correct 103 ms 14788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 12800 KB Output is correct
2 Correct 84 ms 13156 KB Output is correct
3 Correct 82 ms 12828 KB Output is correct
4 Correct 99 ms 12944 KB Output is correct
5 Correct 107 ms 14596 KB Output is correct
6 Correct 82 ms 12740 KB Output is correct
7 Correct 83 ms 13176 KB Output is correct
8 Correct 97 ms 14840 KB Output is correct
9 Correct 103 ms 14532 KB Output is correct
10 Correct 84 ms 12992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 14876 KB Output is correct
2 Correct 111 ms 14748 KB Output is correct
3 Correct 115 ms 14916 KB Output is correct
4 Correct 109 ms 14752 KB Output is correct
5 Correct 113 ms 14884 KB Output is correct
6 Correct 115 ms 14900 KB Output is correct
7 Correct 110 ms 15044 KB Output is correct
8 Correct 124 ms 14984 KB Output is correct
9 Correct 116 ms 15064 KB Output is correct
10 Correct 124 ms 15036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 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 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 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 300 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 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 300 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 328 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 2 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 2 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 14400 KB Output is correct
2 Correct 116 ms 14716 KB Output is correct
3 Correct 100 ms 14912 KB Output is correct
4 Correct 117 ms 14956 KB Output is correct
5 Correct 100 ms 14664 KB Output is correct
6 Correct 93 ms 14396 KB Output is correct
7 Correct 94 ms 14468 KB Output is correct
8 Correct 108 ms 14712 KB Output is correct
9 Correct 90 ms 14412 KB Output is correct
10 Correct 103 ms 14788 KB Output is correct
11 Correct 81 ms 12800 KB Output is correct
12 Correct 84 ms 13156 KB Output is correct
13 Correct 82 ms 12828 KB Output is correct
14 Correct 99 ms 12944 KB Output is correct
15 Correct 107 ms 14596 KB Output is correct
16 Correct 82 ms 12740 KB Output is correct
17 Correct 83 ms 13176 KB Output is correct
18 Correct 97 ms 14840 KB Output is correct
19 Correct 103 ms 14532 KB Output is correct
20 Correct 84 ms 12992 KB Output is correct
21 Correct 116 ms 14876 KB Output is correct
22 Correct 111 ms 14748 KB Output is correct
23 Correct 115 ms 14916 KB Output is correct
24 Correct 109 ms 14752 KB Output is correct
25 Correct 113 ms 14884 KB Output is correct
26 Correct 115 ms 14900 KB Output is correct
27 Correct 110 ms 15044 KB Output is correct
28 Correct 124 ms 14984 KB Output is correct
29 Correct 116 ms 15064 KB Output is correct
30 Correct 124 ms 15036 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 316 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 300 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 324 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 0 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 2 ms 328 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 2 ms 332 KB Output is correct
57 Correct 2 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 332 KB Output is correct
60 Correct 2 ms 328 KB Output is correct
61 Correct 156 ms 14732 KB Output is correct
62 Correct 159 ms 15004 KB Output is correct
63 Correct 119 ms 14660 KB Output is correct
64 Correct 156 ms 14920 KB Output is correct
65 Correct 148 ms 14928 KB Output is correct
66 Correct 152 ms 14880 KB Output is correct
67 Correct 155 ms 14784 KB Output is correct
68 Correct 111 ms 14916 KB Output is correct
69 Correct 112 ms 14660 KB Output is correct
70 Correct 103 ms 14520 KB Output is correct