답안 #680277

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680277 2023-01-10T12:27:53 Z mjhmjh1104 Tortoise (CEOI21_tortoise) C++17
18 / 100
1142 ms 444640 KB
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

int n, a[500006], dist[500006], res, dp[306][606][306][2];
vector<int> playgrounds;

int f(int x, int y, int z, int w) {
    if (dp[x][y][z][w] + 1) return dp[x][y][z][w];
    dp[x][y][z][w] = 0;
    if (2 * x >= y && x >= z && !w && a[x] > 0) dp[x][y][z][w] = max(dp[x][y][z][w], f(x, y, x + 1, 1));
    if (w && a[x] == -1) dp[x][y][z][w] = max(dp[x][y][z][w], f(x, y, z, 0) + 1);
    if (y < 2 * n - 1) {
        if (x > 0) dp[x][y][z][w] = max(dp[x][y][z][w], f(x - 1, y + 1, z, w));
        if (x < n - 1) dp[x][y][z][w] = max(dp[x][y][z][w], f(x + 1, y + 1, z, w));
    } else dp[x][y][z][w] = max(dp[x][y][z][w], w);
    return dp[x][y][z][w];
}

int main() {
    memset(dp, -1, sizeof dp);
    scanf("%d", &n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        sum += max(a[i], 0);
        dist[i] = (int)1e9;
        if (a[i] < 0) playgrounds.push_back(i);
    }
    {
        int tmp = (int)1e9;
        for (int i = 0; i < n; i++) {
            if (a[i] == -1) tmp = 0;
            dist[i] = min(dist[i], tmp);
            tmp++;
        }
        tmp = (int)1e9;
        for (int i = n - 1; i >= 0; i--) {
            if (a[i] == -1) tmp = 0;
            dist[i] = min(dist[i], tmp);
            tmp++;
        }
    }
    printf("%lld", sum - f(0, 0, 0, 0));
}

Compilation message

tortoise.cpp: In function 'int main()':
tortoise.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
tortoise.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         scanf("%d", a + i);
      |         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 444408 KB Output is correct
2 Correct 177 ms 444452 KB Output is correct
3 Correct 183 ms 444416 KB Output is correct
4 Correct 158 ms 444420 KB Output is correct
5 Correct 158 ms 444472 KB Output is correct
6 Correct 162 ms 444448 KB Output is correct
7 Correct 183 ms 444464 KB Output is correct
8 Correct 162 ms 444364 KB Output is correct
9 Correct 166 ms 444420 KB Output is correct
10 Correct 163 ms 444340 KB Output is correct
11 Correct 164 ms 444604 KB Output is correct
12 Correct 169 ms 444396 KB Output is correct
13 Correct 175 ms 444380 KB Output is correct
14 Correct 160 ms 444448 KB Output is correct
15 Correct 162 ms 444436 KB Output is correct
16 Correct 177 ms 444420 KB Output is correct
17 Correct 161 ms 444348 KB Output is correct
18 Correct 170 ms 444500 KB Output is correct
19 Correct 194 ms 444412 KB Output is correct
20 Correct 169 ms 444400 KB Output is correct
21 Correct 171 ms 444440 KB Output is correct
22 Correct 164 ms 444364 KB Output is correct
23 Correct 165 ms 444396 KB Output is correct
24 Correct 161 ms 444456 KB Output is correct
25 Correct 164 ms 444524 KB Output is correct
26 Correct 162 ms 444440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 444408 KB Output is correct
2 Correct 177 ms 444452 KB Output is correct
3 Correct 183 ms 444416 KB Output is correct
4 Correct 158 ms 444420 KB Output is correct
5 Correct 158 ms 444472 KB Output is correct
6 Correct 162 ms 444448 KB Output is correct
7 Correct 183 ms 444464 KB Output is correct
8 Correct 162 ms 444364 KB Output is correct
9 Correct 166 ms 444420 KB Output is correct
10 Correct 163 ms 444340 KB Output is correct
11 Correct 164 ms 444604 KB Output is correct
12 Correct 169 ms 444396 KB Output is correct
13 Correct 175 ms 444380 KB Output is correct
14 Correct 160 ms 444448 KB Output is correct
15 Correct 162 ms 444436 KB Output is correct
16 Correct 177 ms 444420 KB Output is correct
17 Correct 161 ms 444348 KB Output is correct
18 Correct 170 ms 444500 KB Output is correct
19 Correct 194 ms 444412 KB Output is correct
20 Correct 169 ms 444400 KB Output is correct
21 Correct 171 ms 444440 KB Output is correct
22 Correct 164 ms 444364 KB Output is correct
23 Correct 165 ms 444396 KB Output is correct
24 Correct 161 ms 444456 KB Output is correct
25 Correct 164 ms 444524 KB Output is correct
26 Correct 162 ms 444440 KB Output is correct
27 Correct 494 ms 444504 KB Output is correct
28 Correct 1142 ms 444516 KB Output is correct
29 Correct 665 ms 444568 KB Output is correct
30 Correct 493 ms 444460 KB Output is correct
31 Correct 646 ms 444516 KB Output is correct
32 Correct 377 ms 444564 KB Output is correct
33 Correct 568 ms 444408 KB Output is correct
34 Correct 581 ms 444620 KB Output is correct
35 Correct 654 ms 444520 KB Output is correct
36 Correct 653 ms 444640 KB Output is correct
37 Correct 708 ms 444584 KB Output is correct
38 Correct 690 ms 444640 KB Output is correct
39 Correct 716 ms 444616 KB Output is correct
40 Correct 625 ms 444512 KB Output is correct
41 Correct 603 ms 444636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 444408 KB Output is correct
2 Correct 177 ms 444452 KB Output is correct
3 Correct 183 ms 444416 KB Output is correct
4 Correct 158 ms 444420 KB Output is correct
5 Correct 158 ms 444472 KB Output is correct
6 Correct 162 ms 444448 KB Output is correct
7 Correct 183 ms 444464 KB Output is correct
8 Correct 162 ms 444364 KB Output is correct
9 Correct 166 ms 444420 KB Output is correct
10 Correct 163 ms 444340 KB Output is correct
11 Correct 164 ms 444604 KB Output is correct
12 Correct 169 ms 444396 KB Output is correct
13 Correct 175 ms 444380 KB Output is correct
14 Correct 160 ms 444448 KB Output is correct
15 Correct 162 ms 444436 KB Output is correct
16 Correct 177 ms 444420 KB Output is correct
17 Correct 161 ms 444348 KB Output is correct
18 Correct 170 ms 444500 KB Output is correct
19 Correct 194 ms 444412 KB Output is correct
20 Correct 169 ms 444400 KB Output is correct
21 Correct 171 ms 444440 KB Output is correct
22 Correct 164 ms 444364 KB Output is correct
23 Correct 165 ms 444396 KB Output is correct
24 Correct 161 ms 444456 KB Output is correct
25 Correct 164 ms 444524 KB Output is correct
26 Correct 162 ms 444440 KB Output is correct
27 Correct 494 ms 444504 KB Output is correct
28 Correct 1142 ms 444516 KB Output is correct
29 Correct 665 ms 444568 KB Output is correct
30 Correct 493 ms 444460 KB Output is correct
31 Correct 646 ms 444516 KB Output is correct
32 Correct 377 ms 444564 KB Output is correct
33 Correct 568 ms 444408 KB Output is correct
34 Correct 581 ms 444620 KB Output is correct
35 Correct 654 ms 444520 KB Output is correct
36 Correct 653 ms 444640 KB Output is correct
37 Correct 708 ms 444584 KB Output is correct
38 Correct 690 ms 444640 KB Output is correct
39 Correct 716 ms 444616 KB Output is correct
40 Correct 625 ms 444512 KB Output is correct
41 Correct 603 ms 444636 KB Output is correct
42 Incorrect 224 ms 444504 KB Output isn't correct
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 444408 KB Output is correct
2 Correct 177 ms 444452 KB Output is correct
3 Correct 183 ms 444416 KB Output is correct
4 Correct 158 ms 444420 KB Output is correct
5 Correct 158 ms 444472 KB Output is correct
6 Correct 162 ms 444448 KB Output is correct
7 Correct 183 ms 444464 KB Output is correct
8 Correct 162 ms 444364 KB Output is correct
9 Correct 166 ms 444420 KB Output is correct
10 Correct 163 ms 444340 KB Output is correct
11 Correct 164 ms 444604 KB Output is correct
12 Correct 169 ms 444396 KB Output is correct
13 Correct 175 ms 444380 KB Output is correct
14 Correct 160 ms 444448 KB Output is correct
15 Correct 162 ms 444436 KB Output is correct
16 Correct 177 ms 444420 KB Output is correct
17 Correct 161 ms 444348 KB Output is correct
18 Correct 170 ms 444500 KB Output is correct
19 Correct 194 ms 444412 KB Output is correct
20 Correct 169 ms 444400 KB Output is correct
21 Correct 171 ms 444440 KB Output is correct
22 Correct 164 ms 444364 KB Output is correct
23 Correct 165 ms 444396 KB Output is correct
24 Correct 161 ms 444456 KB Output is correct
25 Correct 164 ms 444524 KB Output is correct
26 Correct 162 ms 444440 KB Output is correct
27 Correct 494 ms 444504 KB Output is correct
28 Correct 1142 ms 444516 KB Output is correct
29 Correct 665 ms 444568 KB Output is correct
30 Correct 493 ms 444460 KB Output is correct
31 Correct 646 ms 444516 KB Output is correct
32 Correct 377 ms 444564 KB Output is correct
33 Correct 568 ms 444408 KB Output is correct
34 Correct 581 ms 444620 KB Output is correct
35 Correct 654 ms 444520 KB Output is correct
36 Correct 653 ms 444640 KB Output is correct
37 Correct 708 ms 444584 KB Output is correct
38 Correct 690 ms 444640 KB Output is correct
39 Correct 716 ms 444616 KB Output is correct
40 Correct 625 ms 444512 KB Output is correct
41 Correct 603 ms 444636 KB Output is correct
42 Incorrect 224 ms 444504 KB Output isn't correct
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 444408 KB Output is correct
2 Correct 177 ms 444452 KB Output is correct
3 Correct 183 ms 444416 KB Output is correct
4 Correct 158 ms 444420 KB Output is correct
5 Correct 158 ms 444472 KB Output is correct
6 Correct 162 ms 444448 KB Output is correct
7 Correct 183 ms 444464 KB Output is correct
8 Correct 162 ms 444364 KB Output is correct
9 Correct 166 ms 444420 KB Output is correct
10 Correct 163 ms 444340 KB Output is correct
11 Correct 164 ms 444604 KB Output is correct
12 Correct 169 ms 444396 KB Output is correct
13 Correct 175 ms 444380 KB Output is correct
14 Correct 160 ms 444448 KB Output is correct
15 Correct 162 ms 444436 KB Output is correct
16 Correct 177 ms 444420 KB Output is correct
17 Correct 161 ms 444348 KB Output is correct
18 Correct 170 ms 444500 KB Output is correct
19 Correct 194 ms 444412 KB Output is correct
20 Correct 169 ms 444400 KB Output is correct
21 Correct 171 ms 444440 KB Output is correct
22 Correct 164 ms 444364 KB Output is correct
23 Correct 165 ms 444396 KB Output is correct
24 Correct 161 ms 444456 KB Output is correct
25 Correct 164 ms 444524 KB Output is correct
26 Correct 162 ms 444440 KB Output is correct
27 Correct 494 ms 444504 KB Output is correct
28 Correct 1142 ms 444516 KB Output is correct
29 Correct 665 ms 444568 KB Output is correct
30 Correct 493 ms 444460 KB Output is correct
31 Correct 646 ms 444516 KB Output is correct
32 Correct 377 ms 444564 KB Output is correct
33 Correct 568 ms 444408 KB Output is correct
34 Correct 581 ms 444620 KB Output is correct
35 Correct 654 ms 444520 KB Output is correct
36 Correct 653 ms 444640 KB Output is correct
37 Correct 708 ms 444584 KB Output is correct
38 Correct 690 ms 444640 KB Output is correct
39 Correct 716 ms 444616 KB Output is correct
40 Correct 625 ms 444512 KB Output is correct
41 Correct 603 ms 444636 KB Output is correct
42 Incorrect 224 ms 444504 KB Output isn't correct
43 Halted 0 ms 0 KB -