답안 #1099420

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099420 2024-10-11T09:33:49 Z alexander707070 Tortoise (CEOI21_tortoise) C++14
18 / 100
2 ms 2144 KB
#include<bits/stdc++.h>
#define MAXN 307
using namespace std;

int n,a[MAXN];
int dist[MAXN],last,sum,nxt[MAXN];

int dp[MAXN][2*MAXN][2];
bool li[MAXN][2*MAXN][2];

int ff(int pos,int tim,int c){
    if(tim>2*n or pos>n)return 0;

    if(li[pos][tim][c])return dp[pos][tim][c];
    li[pos][tim][c]=true;

    if(c==1){
        if(nxt[pos]==2*n)dp[pos][tim][c]=0;
        else{
            for(int i=pos+1;i<=nxt[pos];i++){
                dp[pos][tim][c]=max(dp[pos][tim][c],ff(i,tim+2*nxt[pos]-pos-i,0)+1);
            }
        }
    }else{
        if(a[pos]>0){
            if(tim<=2*(pos-1))dp[pos][tim][c]=max(dp[pos][tim][c],ff(pos,tim,1));

            for(int s=0;tim+s*2*dist[pos]<=2*(pos-1) and s+1<=a[pos];s++){
                dp[pos][tim][c]=max(dp[pos][tim][c],ff(pos+1,tim+(s+1)*2*dist[pos]+1,0)+s+1);

                if(s+1<a[pos] and tim+2*(s+1)*dist[pos]>2*(pos-1))dp[pos][tim][c]=max(dp[pos][tim][c], ff(pos,tim+(s+1)*2*dist[pos],1)+s+1);
            }
        }

        if(pos<n)dp[pos][tim][c]=max(dp[pos][tim][c],ff(pos+1,tim+1,c));
    }

    return dp[pos][tim][c];
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        dist[i]=n;

        if(a[i]>=0)sum+=a[i];
    }

    last=-n;
    for(int i=1;i<=n;i++){
        if(a[i]==-1)last=i;
        dist[i]=min(dist[i],i-last);
    }

    last=2*n;
    for(int i=n;i>=1;i--){
        if(a[i]==-1)last=i;
        dist[i]=min(dist[i],last-i);
        
        nxt[i]=last;
    }

    cout<<sum-ff(1,0,0)<<"\n";
 
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 2 ms 1880 KB Output is correct
28 Correct 2 ms 2140 KB Output is correct
29 Correct 2 ms 1884 KB Output is correct
30 Correct 2 ms 1880 KB Output is correct
31 Correct 2 ms 2144 KB Output is correct
32 Correct 1 ms 1628 KB Output is correct
33 Correct 2 ms 1884 KB Output is correct
34 Correct 2 ms 1884 KB Output is correct
35 Correct 1 ms 2140 KB Output is correct
36 Correct 1 ms 2140 KB Output is correct
37 Correct 2 ms 2140 KB Output is correct
38 Correct 2 ms 2140 KB Output is correct
39 Correct 1 ms 2140 KB Output is correct
40 Correct 1 ms 2140 KB Output is correct
41 Correct 1 ms 2140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 2 ms 1880 KB Output is correct
28 Correct 2 ms 2140 KB Output is correct
29 Correct 2 ms 1884 KB Output is correct
30 Correct 2 ms 1880 KB Output is correct
31 Correct 2 ms 2144 KB Output is correct
32 Correct 1 ms 1628 KB Output is correct
33 Correct 2 ms 1884 KB Output is correct
34 Correct 2 ms 1884 KB Output is correct
35 Correct 1 ms 2140 KB Output is correct
36 Correct 1 ms 2140 KB Output is correct
37 Correct 2 ms 2140 KB Output is correct
38 Correct 2 ms 2140 KB Output is correct
39 Correct 1 ms 2140 KB Output is correct
40 Correct 1 ms 2140 KB Output is correct
41 Correct 1 ms 2140 KB Output is correct
42 Incorrect 1 ms 1628 KB Output isn't correct
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 2 ms 1880 KB Output is correct
28 Correct 2 ms 2140 KB Output is correct
29 Correct 2 ms 1884 KB Output is correct
30 Correct 2 ms 1880 KB Output is correct
31 Correct 2 ms 2144 KB Output is correct
32 Correct 1 ms 1628 KB Output is correct
33 Correct 2 ms 1884 KB Output is correct
34 Correct 2 ms 1884 KB Output is correct
35 Correct 1 ms 2140 KB Output is correct
36 Correct 1 ms 2140 KB Output is correct
37 Correct 2 ms 2140 KB Output is correct
38 Correct 2 ms 2140 KB Output is correct
39 Correct 1 ms 2140 KB Output is correct
40 Correct 1 ms 2140 KB Output is correct
41 Correct 1 ms 2140 KB Output is correct
42 Incorrect 1 ms 1628 KB Output isn't correct
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 2 ms 1880 KB Output is correct
28 Correct 2 ms 2140 KB Output is correct
29 Correct 2 ms 1884 KB Output is correct
30 Correct 2 ms 1880 KB Output is correct
31 Correct 2 ms 2144 KB Output is correct
32 Correct 1 ms 1628 KB Output is correct
33 Correct 2 ms 1884 KB Output is correct
34 Correct 2 ms 1884 KB Output is correct
35 Correct 1 ms 2140 KB Output is correct
36 Correct 1 ms 2140 KB Output is correct
37 Correct 2 ms 2140 KB Output is correct
38 Correct 2 ms 2140 KB Output is correct
39 Correct 1 ms 2140 KB Output is correct
40 Correct 1 ms 2140 KB Output is correct
41 Correct 1 ms 2140 KB Output is correct
42 Incorrect 1 ms 1628 KB Output isn't correct
43 Halted 0 ms 0 KB -