답안 #224124

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224124 2020-04-17T08:31:59 Z dantoh000 Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
const int INF = 2000000000;
int n,l;
int x[205], t[205];
int w1[205], w2[205];
int mem[205][205][205][2];
int dp(int i, int j, int t, int k){ ///[i,j], t left, dir k
    if (t < 0) return -INF;
    if (t == 0) return 0;
    if (mem[i][j][t][k] != -1) return mem[i][j][t][k];
    int time = x[i-1] + l-x[j+1];
    int res = 0;
    if (k == 0){
        res = max(res,max(dp(i+1,j,t-(x[i+1]-x[i]),0)+1, dp(i,j-1,t-time,1))+1);
    }
    else{
        res = max(res,max(dp(i,j-1,t-(x[j+1]-x[j]),1)+1, dp(i+1,j,t-time,0))+1);
    }
    return mem[i][j][t][k] = res;
}

int main(){
    scanf("%d%d",&n,&l);
    for (int i = 1; i <= n; i++){
        scanf("%d",&x[i]);
    }
    x[n+1] = l;
    for (int i = 1; i <= n; i++){
        scanf("%d",&t[i]);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++){
        for (int j = n; j >= i; j--){
            int ct = 0;
            int T = 0;
            for (int k = 1; k <= i; k++){
                T += x[k]-x[k-1];
                if (T <= t[k]) ct++;
            }
            T *= 2;
            for (int k = n; k >= j; k--){
                T += x[k+1]-x[k];
                if (T <= t[k]) ct++;
            }
            ans = max(ans,ct);
        }
    }
    for (int i = 1; i <= n; i++){
        for (int j = n; j >= i; j--){
            int ct = 0;
            int T = 0;
            for (int k = n; k >= j; k--){
                T += x[k+1]-x[k];
                if (T <= t[k]) ct++;
            }
            T *= 2;
            for (int k = 1; k <= i; k++){
                T += x[k]-x[k-1];
                if (T <= t[k]) ct++;
            }
            ans = max(ans,ct);
        }
    }
    printf("%d ",ans);


}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:25: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:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x[i]);
         ~~~~~^~~~~~~~~~~~
ho_t3.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&t[i]);
         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -