結果

問題 No.860 買い物
ユーザー i_mrhji_mrhj
提出日時 2019-08-13 05:31:29
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 1,178 ms
コンパイル使用メモリ 31,076 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 09:52:01
合計ジャッジ時間 3,083 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 21 ms
4,348 KB
testcase_12 AC 23 ms
4,348 KB
testcase_13 AC 26 ms
4,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 27 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0