結果
| 問題 |
No.561 東京と京都
|
| コンテスト | |
| ユーザー |
pinebooks
|
| 提出日時 | 2017-08-25 23:16:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 796 bytes |
| コンパイル時間 | 418 ms |
| コンパイル使用メモリ | 49,792 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-15 16:10:32 |
| 合計ジャッジ時間 | 954 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 6 WA * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d%d", &N, &D);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d%d", &ti, &ki);
| ~~~~~^~~~~~~~~~~~~~~~~~
ソースコード
#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