Submission #699887

# Submission time Handle Problem Language Result Execution time Memory
699887 2023-02-18T07:59:43 Z 79brue Tortoise (CEOI21_tortoise) C++17
48 / 100
398 ms 430816 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
int arr[302], sum[302];
int DP[603][302][302][2]; /// 현재 시간, 현재 위치, 산 개수, 손에 든 개수 -> 마지막으로 산 위치
int ans;

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d", &arr[i]);
        sum[i] = sum[i-1];
        if(arr[i] > 0) sum[i] += arr[i];
    }
    for(int i=0; i<=n+n+1; i++) for(int j=0; j<=n; j++) for(int k=0; k<=n; k++) DP[i][j][k][0] = DP[i][j][k][1] = 1e9;

    DP[0][1][0][0] = 0;
    for(int t=0; t<=n+n+1; t++){
        for(int i=1; i<=n; i++){
            for(int j=0; j<=n; j++){
                /// 답 갱신
                for(int c=0; c<2; c++) if(DP[t][i][j][c] < 1e9) ans = max(ans, j);

                /// 시간이 지나지 않는 활동
                if(arr[i] == -1){ /// 산 거 넣기
                    DP[t][i][j][0] = min(DP[t][i][j][0], DP[t][i][j][1]);
                }
                if(arr[i] > 0 && DP[t][i][j][0] < sum[i] && i+i-2 >= t){ /// 사기
                    DP[t][i][j+1][1] = min(DP[t][i][j+1][1], max(DP[t][i][j][0], sum[i-1])+1);
                }

                /// 이동하기
                for(int c=0; c<2; c++){
                    DP[t+1][i-1][j][c] = min(DP[t+1][i-1][j][c], DP[t][i][j][c]);
                    DP[t+1][i+1][j][c] = min(DP[t+1][i+1][j][c], DP[t][i][j][c]);
//                    printf("%d %d %d %d: %d\n", t, i, j, c, DP[t][i][j][c]);
                }
            }
        }
    }

    printf("%d", sum[n] - ans);
}

Compilation message

tortoise.cpp: In function 'int main()':
tortoise.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
tortoise.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d", &arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1840 KB Output is correct
6 Correct 1 ms 1844 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1836 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1876 KB Output is correct
15 Correct 1 ms 1844 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1876 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 1 ms 1876 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1876 KB Output is correct
23 Correct 2 ms 1876 KB Output is correct
24 Correct 1 ms 1876 KB Output is correct
25 Correct 1 ms 1844 KB Output is correct
26 Correct 1 ms 1844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1840 KB Output is correct
6 Correct 1 ms 1844 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1836 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1876 KB Output is correct
15 Correct 1 ms 1844 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1876 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 1 ms 1876 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1876 KB Output is correct
23 Correct 2 ms 1876 KB Output is correct
24 Correct 1 ms 1876 KB Output is correct
25 Correct 1 ms 1844 KB Output is correct
26 Correct 1 ms 1844 KB Output is correct
27 Correct 228 ms 299396 KB Output is correct
28 Correct 358 ms 410520 KB Output is correct
29 Correct 342 ms 372412 KB Output is correct
30 Correct 252 ms 313932 KB Output is correct
31 Correct 360 ms 416080 KB Output is correct
32 Correct 154 ms 223992 KB Output is correct
33 Correct 286 ms 361920 KB Output is correct
34 Correct 242 ms 313800 KB Output is correct
35 Correct 368 ms 430712 KB Output is correct
36 Correct 398 ms 430708 KB Output is correct
37 Correct 385 ms 430704 KB Output is correct
38 Correct 366 ms 430704 KB Output is correct
39 Correct 344 ms 430816 KB Output is correct
40 Correct 380 ms 430712 KB Output is correct
41 Correct 349 ms 430708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1840 KB Output is correct
6 Correct 1 ms 1844 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1836 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1876 KB Output is correct
15 Correct 1 ms 1844 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1876 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 1 ms 1876 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1876 KB Output is correct
23 Correct 2 ms 1876 KB Output is correct
24 Correct 1 ms 1876 KB Output is correct
25 Correct 1 ms 1844 KB Output is correct
26 Correct 1 ms 1844 KB Output is correct
27 Correct 228 ms 299396 KB Output is correct
28 Correct 358 ms 410520 KB Output is correct
29 Correct 342 ms 372412 KB Output is correct
30 Correct 252 ms 313932 KB Output is correct
31 Correct 360 ms 416080 KB Output is correct
32 Correct 154 ms 223992 KB Output is correct
33 Correct 286 ms 361920 KB Output is correct
34 Correct 242 ms 313800 KB Output is correct
35 Correct 368 ms 430712 KB Output is correct
36 Correct 398 ms 430708 KB Output is correct
37 Correct 385 ms 430704 KB Output is correct
38 Correct 366 ms 430704 KB Output is correct
39 Correct 344 ms 430816 KB Output is correct
40 Correct 380 ms 430712 KB Output is correct
41 Correct 349 ms 430708 KB Output is correct
42 Correct 139 ms 200044 KB Output is correct
43 Correct 154 ms 209864 KB Output is correct
44 Correct 221 ms 273824 KB Output is correct
45 Correct 306 ms 383168 KB Output is correct
46 Correct 178 ms 249348 KB Output is correct
47 Correct 139 ms 197964 KB Output is correct
48 Correct 250 ms 323696 KB Output is correct
49 Correct 196 ms 253660 KB Output is correct
50 Correct 279 ms 359280 KB Output is correct
51 Correct 334 ms 394032 KB Output is correct
52 Correct 161 ms 215960 KB Output is correct
53 Correct 301 ms 380444 KB Output is correct
54 Correct 314 ms 377776 KB Output is correct
55 Correct 240 ms 313884 KB Output is correct
56 Correct 330 ms 418896 KB Output is correct
57 Correct 165 ms 209868 KB Output is correct
58 Correct 299 ms 372428 KB Output is correct
59 Correct 181 ms 242892 KB Output is correct
60 Correct 291 ms 328636 KB Output is correct
61 Correct 323 ms 359296 KB Output is correct
62 Correct 281 ms 364664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1840 KB Output is correct
6 Correct 1 ms 1844 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1836 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1876 KB Output is correct
15 Correct 1 ms 1844 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1876 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 1 ms 1876 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1876 KB Output is correct
23 Correct 2 ms 1876 KB Output is correct
24 Correct 1 ms 1876 KB Output is correct
25 Correct 1 ms 1844 KB Output is correct
26 Correct 1 ms 1844 KB Output is correct
27 Correct 228 ms 299396 KB Output is correct
28 Correct 358 ms 410520 KB Output is correct
29 Correct 342 ms 372412 KB Output is correct
30 Correct 252 ms 313932 KB Output is correct
31 Correct 360 ms 416080 KB Output is correct
32 Correct 154 ms 223992 KB Output is correct
33 Correct 286 ms 361920 KB Output is correct
34 Correct 242 ms 313800 KB Output is correct
35 Correct 368 ms 430712 KB Output is correct
36 Correct 398 ms 430708 KB Output is correct
37 Correct 385 ms 430704 KB Output is correct
38 Correct 366 ms 430704 KB Output is correct
39 Correct 344 ms 430816 KB Output is correct
40 Correct 380 ms 430712 KB Output is correct
41 Correct 349 ms 430708 KB Output is correct
42 Correct 139 ms 200044 KB Output is correct
43 Correct 154 ms 209864 KB Output is correct
44 Correct 221 ms 273824 KB Output is correct
45 Correct 306 ms 383168 KB Output is correct
46 Correct 178 ms 249348 KB Output is correct
47 Correct 139 ms 197964 KB Output is correct
48 Correct 250 ms 323696 KB Output is correct
49 Correct 196 ms 253660 KB Output is correct
50 Correct 279 ms 359280 KB Output is correct
51 Correct 334 ms 394032 KB Output is correct
52 Correct 161 ms 215960 KB Output is correct
53 Correct 301 ms 380444 KB Output is correct
54 Correct 314 ms 377776 KB Output is correct
55 Correct 240 ms 313884 KB Output is correct
56 Correct 330 ms 418896 KB Output is correct
57 Correct 165 ms 209868 KB Output is correct
58 Correct 299 ms 372428 KB Output is correct
59 Correct 181 ms 242892 KB Output is correct
60 Correct 291 ms 328636 KB Output is correct
61 Correct 323 ms 359296 KB Output is correct
62 Correct 281 ms 364664 KB Output is correct
63 Incorrect 0 ms 212 KB Output isn't correct
64 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1840 KB Output is correct
6 Correct 1 ms 1844 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1836 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1876 KB Output is correct
15 Correct 1 ms 1844 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1876 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 1 ms 1876 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1876 KB Output is correct
23 Correct 2 ms 1876 KB Output is correct
24 Correct 1 ms 1876 KB Output is correct
25 Correct 1 ms 1844 KB Output is correct
26 Correct 1 ms 1844 KB Output is correct
27 Correct 228 ms 299396 KB Output is correct
28 Correct 358 ms 410520 KB Output is correct
29 Correct 342 ms 372412 KB Output is correct
30 Correct 252 ms 313932 KB Output is correct
31 Correct 360 ms 416080 KB Output is correct
32 Correct 154 ms 223992 KB Output is correct
33 Correct 286 ms 361920 KB Output is correct
34 Correct 242 ms 313800 KB Output is correct
35 Correct 368 ms 430712 KB Output is correct
36 Correct 398 ms 430708 KB Output is correct
37 Correct 385 ms 430704 KB Output is correct
38 Correct 366 ms 430704 KB Output is correct
39 Correct 344 ms 430816 KB Output is correct
40 Correct 380 ms 430712 KB Output is correct
41 Correct 349 ms 430708 KB Output is correct
42 Correct 139 ms 200044 KB Output is correct
43 Correct 154 ms 209864 KB Output is correct
44 Correct 221 ms 273824 KB Output is correct
45 Correct 306 ms 383168 KB Output is correct
46 Correct 178 ms 249348 KB Output is correct
47 Correct 139 ms 197964 KB Output is correct
48 Correct 250 ms 323696 KB Output is correct
49 Correct 196 ms 253660 KB Output is correct
50 Correct 279 ms 359280 KB Output is correct
51 Correct 334 ms 394032 KB Output is correct
52 Correct 161 ms 215960 KB Output is correct
53 Correct 301 ms 380444 KB Output is correct
54 Correct 314 ms 377776 KB Output is correct
55 Correct 240 ms 313884 KB Output is correct
56 Correct 330 ms 418896 KB Output is correct
57 Correct 165 ms 209868 KB Output is correct
58 Correct 299 ms 372428 KB Output is correct
59 Correct 181 ms 242892 KB Output is correct
60 Correct 291 ms 328636 KB Output is correct
61 Correct 323 ms 359296 KB Output is correct
62 Correct 281 ms 364664 KB Output is correct
63 Incorrect 0 ms 212 KB Output isn't correct
64 Halted 0 ms 0 KB -