結果

問題 No.561 東京と京都
ユーザー 一ノ瀬卯月一ノ瀬卯月
提出日時 2019-03-11 15:34:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 60,692 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 20:08:10
合計ジャッジ時間 1,352 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,380 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>
using namespace std;
int main()
{
	int d, c, p=0;	// day, cost, pay
	bool l = false;			// locate (tr=kyoto,fal=tongking)
	vector<int>t, k;	// tongking,kyoto
	cin >> d >> c;
	t.resize(d);
	k.resize(d);
	for (int i = 0; i < d; i++)	// entermoney
	{
		cin >> t[i] >> k[i];
	}

	for (int i = 0; i < d; i++)
	{
		if (l==false)
		{
			if (t[i] > k[i] - c)
			{
				p += t[i];
			}

			else if (t[i] < k[i] - c)
			{
				p += k[i] - c;
				l = true;
			}

			else
			{
				p += t[i];
				if (t[i + 1] < k[i + 1] - c) l = true;
			}
		}

		else
		{
			if (t[i] - c < k[i])
			{
				p += k[i];
			}

			else if (t[i] - c > k[i])
			{
				p += t[i] - c;
				l = false;
			}

			else
			{
				p += k[i];
				if (t[i + 1] - c > k[i + 1]) l = false;
			}
		}
	}

	cout << p << endl;
	return 0;
}
0