結果
| 問題 | No.561 東京と京都 |
| コンテスト | |
| ユーザー |
pinebooks
|
| 提出日時 | 2017-08-25 23:16:44 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 796 bytes |
| 記録 | |
| コンパイル時間 | 300 ms |
| コンパイル使用メモリ | 70,832 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-05-05 00:27:07 |
| 合計ジャッジ時間 | 1,162 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 6 WA * 11 |
ソースコード
#include <cstdio>
#include <vector>
#include <string>
using namespace std;
int main() {
int N, D;
scanf("%d%d", &N, &D);
vector<int> T, K;
for (int i = 0; i < N; ++i) {
int ti, ki;
scanf("%d%d", &ti, &ki);
T.push_back(ti);
K.push_back(ki);
}
string current_location = "Tokyo";
int real_tokyo_payment;
int real_kyoto_payment;
int salary = 0;
for (int i = 0; i < N; ++i) {
real_tokyo_payment = current_location == "Tokyo" ? T[i] : T[i] - D;
real_kyoto_payment = current_location == "Kyoto" ? K[i] : K[i] - D;
if (real_tokyo_payment >= real_kyoto_payment) {
salary += real_tokyo_payment;
current_location = "Tokyo";
} else {
salary += real_kyoto_payment;
current_location = "Kyoto";
}
}
printf("%d\n", salary);
}
pinebooks