結果

問題 No.561 東京と京都
ユーザー newlife171128newlife171128
提出日時 2018-01-03 23:01:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,399 bytes
コンパイル時間 451 ms
コンパイル使用メモリ 66,880 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 18:03:59
合計ジャッジ時間 1,381 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <cctype>
using namespace std;

int Tokyo_fee[100];
int Kyoto_fee[100];

int main() {

	int n =0,d=0;
	cin>>n>>d;

	long Tokyo_max =0;
	long Kyoto_max =0;
	int tmp=0;
	for(int i=0; i<n;i++){
		cin>>tmp;
		Tokyo_fee[i] =tmp;
		cin>>tmp;
		Kyoto_fee[i] =tmp;
	}

	Tokyo_max = 0;
	Kyoto_max = Kyoto_fee[0]-d;

/*	long tmpp=0;*/
	bool judge = true;
	int i=0;
	for( i=0; i<n; i++){

		if(judge){
		Tokyo_max = max(Tokyo_max+Kyoto_fee[i]-d,Tokyo_max+Tokyo_fee[i]);
/*		Tokyo_max +=tmpp;*/
		if(Tokyo_max+Kyoto_fee[i]-d>Tokyo_max+Tokyo_fee[i]){
			judge = false;
		}
		if(Tokyo_max+Kyoto_fee[i]-d==Tokyo_max+Tokyo_fee[i]){
			i++;
			if(Tokyo_max+Kyoto_fee[i]-d>Tokyo_max+Tokyo_fee[i]){
						judge = false;
					}
			Tokyo_max = max(Tokyo_max+Kyoto_fee[i]-d,Tokyo_max+Tokyo_fee[i]);
		}

		}else {

		Tokyo_max = max(Tokyo_max+Tokyo_fee[i]-d,Tokyo_max+Kyoto_fee[i]);
/*		Kyoto_max +=tmpp;*/
		if(Kyoto_max+Tokyo_fee[i]-d>Kyoto_max+Kyoto_fee[i]){
			judge = true;
		}
		if(Kyoto_max+Tokyo_fee[i]-d==Kyoto_max+Kyoto_fee[i]){
			i++;
			if(Kyoto_max+Tokyo_fee[i]-d>Kyoto_max+Kyoto_fee[i]){
					judge = true;
				}
			Tokyo_max = max(Tokyo_max+Tokyo_fee[i]-d,Tokyo_max+Kyoto_fee[i]);
		}

		}

/*		cout<<i<<Tokyo_max<<endl;*/


	}

	cout<<Tokyo_max<<endl;

	return 0;
}
0