結果

問題 No.561 東京と京都
ユーザー BucchimanBucchiman
提出日時 2020-04-04 11:12:16
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 826 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 28,508 KB
実行使用メモリ 6,072 KB
最終ジャッジ日時 2023-09-16 05:31:35
合計ジャッジ時間 3,819 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 0 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
 * FileName:     no_561_tokyo_kyoto
 * CreatedDate:  2020-04-04 10:48:11 +0900
 * LastModified: 2020-04-04 11:10:50 +0900
 */

#include <stdio.h>
int max(int s, int t){
    if(s>t){ return s; }
    else{ return t; }
}
int dp( int i, int N, int D, int T[], int K[], int bi){
    if(i==N){
        return 0;
    }
    else if( bi==0 ){
        int box_0 = dp(i+1,N,D,T,K,0)+T[i];
        int box_1 = dp(i+1,N,D,T,K,1)+K[i]-D;
        return max(box_0,box_1);
    }
    else{
        int box_0 = dp(i+1,N,D,T,K,0)+T[i]-D;
        int box_1 = dp(i+1,N,D,T,K,1)+K[i];
        return max(box_0,box_1);
    }
}
int main(void){
    int N, D;
    scanf("%d %d",&N,&D);
    int T[N],K[N];
    for(int i=0;i<N;i++){
        scanf("%d %d",&T[i], &K[i]);
    }
    int tmp_0 = dp(0,N,D,T,K,0);
    printf("%d\n",tmp_0);
    return 0;
}
0