답안 #224024

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224024 2020-04-17T05:11:53 Z cheeheng Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

int X[205];
int T[205];

int main(){
    int N, L;
    scanf("%d%d", &N, &L);

    X[0] = 0;
    for(int i = 1; i <= N; i ++){
        scanf("%d", &X[i]);
    }
    X[N+1] = L;

    T[0] = 0;
    for(int i = 1; i <= N; i ++){
        scanf("%d", &T[i]);
    }
    T[N+1] = 0;

    // clockwise, then anticlockwise
    int ans = 0;
    for(int i = 0; i <= N; i ++){
        int temp = 0;

        long long t_taken = 0;
        for(int k = 1; k <= i; k ++){
            t_taken += X[k]-X[k-1];
            if(t_taken <= T[k]){
                temp ++;
            }
        }

        t_taken *= 2;
        for(int j = N; j >= i+1; j --){
            t_taken += X[j+1]-X[j];
            if(t_taken <= T[j]){
                temp ++;
            }
        }

        ans = max(temp, ans);
    }

    // anticlockwise, then clockwise
    for(int i = 0; i <= N; i ++){
        int temp = 0;

        long long t_taken = 0;
        for(int j = N; j >= i+1; j --){
            t_taken += X[j+1]-X[j];
            if(t_taken <= T[j]){
                temp ++;
            }
        }

        t_taken *= 2;

        for(int k = 1; k <= i; k ++){
            t_taken += X[k]-X[k-1];
            if(t_taken <= T[k]){
                temp ++;
            }
        }

        ans = max(temp, ans);
    }

    printf("%d", ans);

    return 0;
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:9: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:13: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:19: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 4 ms 256 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -