結果
| 問題 |
No.860 買い物
|
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-09-22 21:04:11 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 1,000 ms |
| コード長 | 549 bytes |
| コンパイル時間 | 96 ms |
| コンパイル使用メモリ | 29,440 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 03:43:19 |
| 合計ジャッジ時間 | 1,616 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 |
ソースコード
// yukicoder 860 買い物
// 2019.9.22 bal4u
#include <stdio.h>
typedef long long ll;
int getchar_unlocked(void);
#define gc() getchar_unlocked()
int in() { // 非負整数の入力
int n = 0, c = gc();
do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
return n;
}
inline static ll MIN(ll a, ll b) { return a <= b? a: b; }
int main()
{
int N, C, D;
ll s, t;
N = in(); C = in(), D = in();
t = C, s = t << 1;
while (--N) {
C = in(), D = in();
t = MIN(t+D, s) + C;
s = MIN(s+D, t) + C;
}
printf("%lld\n", s);
return 0;
}
bal4u