結果

問題 No.561 東京と京都
ユーザー BucchimanBucchiman
提出日時 2020-04-04 11:23:00
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,006 bytes
コンパイル時間 405 ms
コンパイル使用メモリ 21,376 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-03 07:06:06
合計ジャッジ時間 3,838 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 0 ms
5,376 KB
testcase_08 AC 0 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:30:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |     scanf("%d %ld",&N,&D);
      |     ^~~~~~~~~~~~~~~~~~~~~
main.c:33:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |         scanf("%ld %ld",&T[i], &K[i]);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

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

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