結果

問題 No.860 買い物
コンテスト
ユーザー i_mrhj
提出日時 2019-08-13 05:31:29
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 687 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 198 ms
コンパイル使用メモリ 41,820 KB
最終ジャッジ日時 2026-02-22 04:14:38
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 5 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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