# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
497861 | 2021-12-24T02:03:07 Z | amukkalir | Bali Sculptures (APIO15_sculpture) | C++17 | 5 ms | 348 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pii pair<int,int> #define fi first #define se second const ll INF = LLONG_MAX; const int nax = 100; ll dp[nax+5][nax+5]; ll p[nax+5]; int n; ll f (int rem, int idx) { if(idx==n+1) return (rem==0)?0:INF; if(rem<=0) return INF; ll &res = dp[rem][idx]; if(~res) return res; res = INF; for(int i=idx; i<=n; i++) { res = min(res, p[i]-p[idx-1] | f(rem-1, i+1)); } return res; } signed main () { int a, b; scanf("%d%d%d", &n, &a, &b); for(int i=1; i<=n; i++) { ll y; scanf("%lld", &y); p[i] = p[i-1] + y; } ll ans = INF; memset(dp, -1, sizeof dp); for(int i=a; i<=b; i++) { ans = min(ans, f(i, 1)); //cout << i << " " << f(i, 0) << endl; } printf("%lld", ans); } /* YES 3 1 3 YES 1 NO YES 5 5 4 1 4 5 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 332 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 292 KB | Output is correct |
17 | Correct | 0 ms | 292 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 0 ms | 332 KB | Output is correct |
20 | Correct | 0 ms | 332 KB | Output is correct |
21 | Incorrect | 0 ms | 332 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 292 KB | Output is correct |
17 | Correct | 1 ms | 292 KB | Output is correct |
18 | Correct | 1 ms | 296 KB | Output is correct |
19 | Correct | 0 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Incorrect | 0 ms | 332 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 332 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
16 | Correct | 0 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 | 0 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 0 ms | 332 KB | Output is correct |
23 | Correct | 0 ms | 332 KB | Output is correct |
24 | Correct | 1 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 2 ms | 332 KB | Output is correct |
28 | Correct | 5 ms | 332 KB | Output is correct |
29 | Correct | 3 ms | 332 KB | Output is correct |
30 | Correct | 0 ms | 332 KB | Output is correct |
31 | Correct | 2 ms | 332 KB | Output is correct |
32 | Correct | 3 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 292 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 0 ms | 292 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Incorrect | 1 ms | 332 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 0 ms | 332 KB | Output is correct |
17 | Correct | 0 ms | 332 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 0 ms | 332 KB | Output is correct |
20 | Correct | 0 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 0 ms | 336 KB | Output is correct |
23 | Correct | 0 ms | 336 KB | Output is correct |
24 | Correct | 0 ms | 336 KB | Output is correct |
25 | Correct | 0 ms | 336 KB | Output is correct |
26 | Correct | 0 ms | 336 KB | Output is correct |
27 | Correct | 1 ms | 336 KB | Output is correct |
28 | Correct | 1 ms | 344 KB | Output is correct |
29 | Correct | 1 ms | 344 KB | Output is correct |
30 | Correct | 0 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 344 KB | Output is correct |
34 | Correct | 0 ms | 344 KB | Output is correct |
35 | Correct | 0 ms | 344 KB | Output is correct |
36 | Correct | 1 ms | 344 KB | Output is correct |
37 | Correct | 1 ms | 344 KB | Output is correct |
38 | Correct | 3 ms | 344 KB | Output is correct |
39 | Correct | 3 ms | 344 KB | Output is correct |
40 | Correct | 0 ms | 344 KB | Output is correct |
41 | Correct | 2 ms | 348 KB | Output is correct |
42 | Correct | 3 ms | 344 KB | Output is correct |
43 | Incorrect | 0 ms | 344 KB | Output isn't correct |
44 | Halted | 0 ms | 0 KB | - |