結果
| 問題 |
No.561 東京と京都
|
| コンテスト | |
| ユーザー |
cb_4150
|
| 提出日時 | 2017-08-26 00:32:00 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 521 bytes |
| コンパイル時間 | 254 ms |
| コンパイル使用メモリ | 34,272 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-15 16:53:05 |
| 合計ジャッジ時間 | 954 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d %d", &n, &d);
| ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%d %d", &t[i], &k[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <algorithm>
#define MAX 100
int n, d, t[MAX], k[MAX], dp[MAX][MAX];
int main(){
scanf("%d %d", &n, &d);
for(int i = 0; i < n; i++){
scanf("%d %d", &t[i], &k[i]);
}
dp[0][0] = t[0], dp[0][1] = k[0] - d;
for(int i = 1; i < n; i++){
dp[i][0] = std::max(dp[i - 1][0] + t[i], dp[i - 1][1] + t[i] - d);
dp[i][1] = std::max(dp[i - 1][1] + k[i], dp[i - 1][0] + k[i] - d);
}
printf("%d\n", std::max(dp[n - 1][0], dp[n - 1][1]));
return 0;
}
cb_4150