結果
| 問題 |
No.860 買い物
|
| コンテスト | |
| ユーザー |
i_mrhj
|
| 提出日時 | 2019-08-13 05:31:29 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 687 bytes |
| コンパイル時間 | 292 ms |
| コンパイル使用メモリ | 31,232 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 06:04:08 |
| 合計ジャッジ時間 | 2,361 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 5 WA * 10 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
int
main(int argc, char *argv[])
{
ll c[100000], d[100000];
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%lld %lld", &c[i], &d[i]);
ll cost[100000];
cost[0] = 2 * c[0];
for (int i = 1; i < n; i++)
cost[i] = cost[i - 1] + Min(Min(2 * c[i], c[i] + d[i]), 2 * c[i] - c[i - 1] + d[i]);
printf("%lld\n", cost[n - 1]);
return 0;
}
i_mrhj