結果

問題 No.561 東京と京都
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-18 14:27:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 311 bytes
コンパイル時間 1,877 ms
コンパイル使用メモリ 194,672 KB
実行使用メモリ 6,952 KB
最終ジャッジ日時 2024-04-09 02:11:55
合計ジャッジ時間 2,884 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:9:6: warning: 'd' is used uninitialized [-Wuninitialized]
    9 |     k-=d;
      |     ~^~~
main.cpp:6:11: note: 'd' was declared here
    6 |     int n,d;
      |           ^
main.cpp:10:19: warning: 'n' is used uninitialized [-Wuninitialized]
   10 |     for (int i=1;i<n;i++) {
      |                  ~^~
main.cpp:6:9: note: 'n' was declared here
    6 |     int n,d;
      |         ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n,d;
    int t,k;
    cin>>t>>k;
    k-=d;
    for (int i=1;i<n;i++) {
        int a,b;
        cin>>a>>b;
        int pt=t;
        t=a+max(t,k-d);
        k=b+max(pt-d,k);
    }
    cout<<max(t,k)<<endl;
    return 0;
}
0