답안 #224042

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224042 2020-04-17T05:59:03 Z tqbfjotld Collecting Stamps 3 (JOI20_ho_t3) C++14
15 / 100
200 ms 67840 KB
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000009
#define DEBUG false

int pos[205];
int reqt[205];
bool collected[205];
int n,L;
int memo[205][205][205][2];

int func(int l, int r, int num, bool side){
    if (l==0 && r==0){
        return num==0?0:INF;
    }
    if (l==0){
        if (!side) return memo[l][r][num][side] = INF;
    }
    if (r==0){
        if (side) return memo[l][r][num][side] = INF;
    }
    if (num<=0){
        return side?pos[r-1]:(L-pos[n-l]);
    }
    if (memo[l][r][num][side]!=-1) return memo[l][r][num][side];


    if (side){
        int ans = INF;
        ans = min(ans,func(l,r-1,num,true)+pos[r-1]-pos[r-2]);
        if (DEBUG) printf("%d %d\n",ans,func(l,r-1,num,true));
        ans = min(ans,func(l,r-1,num,false)+pos[r-1]+L-pos[n-l]);
        if (DEBUG) printf("%d\n",ans);
        int t = func(l,r-1,num-1,true);
        if (t+pos[r-1]-pos[r-2]<=reqt[r-1]){
            ans = min(ans,t+pos[r-1]-pos[r-2]);
        }
        if (DEBUG) printf("%d\n",ans);
        t = func(l,r-1,num-1,false);
        if (t+pos[r-1]+L-pos[n-l]<=reqt[r-1]){
            ans = min(ans,t+pos[r-1]+L-pos[n-1]);
        }
        if (DEBUG) printf("%d\n",ans);
        return memo[l][r][num][side] = ans;
    }
    else{
        int ans = INF;
        ans = min(ans,func(l-1,r,num,true)+pos[r-1]+L-pos[n-l]);
        ans = min(ans,func(l-1,r,num,false)+pos[n-l+1]-pos[n-l]);
        int t = func(l-1,r,num-1,true);
        if (t+pos[r-1]+L-pos[n-l]<=reqt[n-l]){
            ans = min(ans,t+pos[r-1]+L-pos[n-l]);
        }
        t = func(l-1,r,num-1,false);
        if (t+pos[n-l+1]-pos[n-l]<=reqt[n-l]){
            ans = min(ans,t+pos[n-l+1]-pos[n-l]);
        }
        return memo[l][r][num][side] = ans;
    }
}

int main(){
    scanf("%d%d",&n,&L);
    for (int x = 0; x<n; x++){
        scanf("%d",&pos[x]);
    }
    for (int x = 0; x<n; x++){
        scanf("%d",&reqt[x]);
    }
    pos[n] = L;
    reqt[n] = INF;
    memset(memo,-1,sizeof(memo));
    int ans = 0;
    for (int x = 0; x<=n; x++){
        for (int t = 0; t<=n; t++){
             //   printf("time for %d to %d, %d stamps, end at right = %d\n",-x,n-x,t,func(x,n-x,t,true));
            if (func(x,n-x,t,true)<INF){

                ans = max(ans,t);
            }
            if (func(x,n-x,t,false)<INF){
                ans = max(ans,t);
            }
        }
    }
    printf("%d",ans);
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:63:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&L);
     ~~~~~^~~~~~~~~~~~~~
ho_t3.cpp:65:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&pos[x]);
         ~~~~~^~~~~~~~~~~~~~
ho_t3.cpp:68:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&reqt[x]);
         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 67832 KB Output is correct
2 Correct 37 ms 67704 KB Output is correct
3 Correct 38 ms 67832 KB Output is correct
4 Correct 37 ms 67840 KB Output is correct
5 Correct 38 ms 67832 KB Output is correct
6 Correct 37 ms 67704 KB Output is correct
7 Correct 37 ms 67704 KB Output is correct
8 Correct 37 ms 67704 KB Output is correct
9 Correct 37 ms 67704 KB Output is correct
10 Correct 39 ms 67704 KB Output is correct
11 Correct 37 ms 67712 KB Output is correct
12 Correct 42 ms 67704 KB Output is correct
13 Correct 37 ms 67708 KB Output is correct
14 Correct 38 ms 67712 KB Output is correct
15 Correct 37 ms 67704 KB Output is correct
16 Correct 43 ms 67704 KB Output is correct
17 Correct 37 ms 67712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 67832 KB Output is correct
2 Correct 37 ms 67704 KB Output is correct
3 Correct 38 ms 67832 KB Output is correct
4 Correct 37 ms 67840 KB Output is correct
5 Correct 38 ms 67832 KB Output is correct
6 Correct 37 ms 67704 KB Output is correct
7 Correct 37 ms 67704 KB Output is correct
8 Correct 37 ms 67704 KB Output is correct
9 Correct 37 ms 67704 KB Output is correct
10 Correct 39 ms 67704 KB Output is correct
11 Correct 37 ms 67712 KB Output is correct
12 Correct 42 ms 67704 KB Output is correct
13 Correct 37 ms 67708 KB Output is correct
14 Correct 38 ms 67712 KB Output is correct
15 Correct 37 ms 67704 KB Output is correct
16 Correct 43 ms 67704 KB Output is correct
17 Correct 37 ms 67712 KB Output is correct
18 Correct 37 ms 67704 KB Output is correct
19 Correct 37 ms 67712 KB Output is correct
20 Correct 43 ms 67704 KB Output is correct
21 Correct 41 ms 67704 KB Output is correct
22 Correct 41 ms 67704 KB Output is correct
23 Correct 42 ms 67704 KB Output is correct
24 Correct 41 ms 67708 KB Output is correct
25 Correct 37 ms 67832 KB Output is correct
26 Correct 37 ms 67704 KB Output is correct
27 Correct 37 ms 67704 KB Output is correct
28 Correct 41 ms 67704 KB Output is correct
29 Correct 37 ms 67832 KB Output is correct
30 Correct 42 ms 67832 KB Output is correct
31 Correct 38 ms 67712 KB Output is correct
32 Correct 37 ms 67704 KB Output is correct
33 Correct 38 ms 67712 KB Output is correct
34 Correct 38 ms 67712 KB Output is correct
35 Correct 38 ms 67832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 67832 KB Output is correct
2 Correct 37 ms 67704 KB Output is correct
3 Correct 38 ms 67832 KB Output is correct
4 Correct 37 ms 67840 KB Output is correct
5 Correct 38 ms 67832 KB Output is correct
6 Correct 37 ms 67704 KB Output is correct
7 Correct 37 ms 67704 KB Output is correct
8 Correct 37 ms 67704 KB Output is correct
9 Correct 37 ms 67704 KB Output is correct
10 Correct 39 ms 67704 KB Output is correct
11 Correct 37 ms 67712 KB Output is correct
12 Correct 42 ms 67704 KB Output is correct
13 Correct 37 ms 67708 KB Output is correct
14 Correct 38 ms 67712 KB Output is correct
15 Correct 37 ms 67704 KB Output is correct
16 Correct 43 ms 67704 KB Output is correct
17 Correct 37 ms 67712 KB Output is correct
18 Incorrect 200 ms 67840 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 67832 KB Output is correct
2 Correct 37 ms 67704 KB Output is correct
3 Correct 38 ms 67832 KB Output is correct
4 Correct 37 ms 67840 KB Output is correct
5 Correct 38 ms 67832 KB Output is correct
6 Correct 37 ms 67704 KB Output is correct
7 Correct 37 ms 67704 KB Output is correct
8 Correct 37 ms 67704 KB Output is correct
9 Correct 37 ms 67704 KB Output is correct
10 Correct 39 ms 67704 KB Output is correct
11 Correct 37 ms 67712 KB Output is correct
12 Correct 42 ms 67704 KB Output is correct
13 Correct 37 ms 67708 KB Output is correct
14 Correct 38 ms 67712 KB Output is correct
15 Correct 37 ms 67704 KB Output is correct
16 Correct 43 ms 67704 KB Output is correct
17 Correct 37 ms 67712 KB Output is correct
18 Correct 37 ms 67704 KB Output is correct
19 Correct 37 ms 67712 KB Output is correct
20 Correct 43 ms 67704 KB Output is correct
21 Correct 41 ms 67704 KB Output is correct
22 Correct 41 ms 67704 KB Output is correct
23 Correct 42 ms 67704 KB Output is correct
24 Correct 41 ms 67708 KB Output is correct
25 Correct 37 ms 67832 KB Output is correct
26 Correct 37 ms 67704 KB Output is correct
27 Correct 37 ms 67704 KB Output is correct
28 Correct 41 ms 67704 KB Output is correct
29 Correct 37 ms 67832 KB Output is correct
30 Correct 42 ms 67832 KB Output is correct
31 Correct 38 ms 67712 KB Output is correct
32 Correct 37 ms 67704 KB Output is correct
33 Correct 38 ms 67712 KB Output is correct
34 Correct 38 ms 67712 KB Output is correct
35 Correct 38 ms 67832 KB Output is correct
36 Incorrect 200 ms 67840 KB Output isn't correct
37 Halted 0 ms 0 KB -