Submission #1691038


Source Code Expand

#include <bits/stdc++.h>

using namespace std;
 
// macro
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ll long long
#define ull unsigned long long
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define SORT(ary) sort(begin(ary), end(ary))
#define VL vector<ll>
#define VVL vector<VL>
#define PL pair<ll, ll>
#define VC vector<char>
#define VVC vector<VC>

// Factorial
// need init
ll factorial_memo[5001];
ll factorial(ll n) {
  factorial_memo[0] = 1;
  if(factorial_memo[n] != -1) return factorial_memo[n];
  factorial_memo[n] = (factorial(n-1) * n) % MOD;
  return factorial_memo[n];
}
 
// Combination(nCr)
// need init
ll nCr_memo[5001][5001];
ll nCr(ll n, ll r) {
  if(r*2 > n) r = n-r;
  if(r == 1) return n;
  if(r == 0) return 1;
  if(nCr_memo[n][r] != -1) return nCr_memo[n][r];
  nCr_memo[n][r] = (nCr(n-1, r) + nCr(n-1, r-1)) % MOD;
  return nCr_memo[n][r];
}

ll dfs(VVL& g, vector<PL>& res, ll v, ll& count, ll from, VL& low, VL& pre) {
  pre[v] = count++;
  low[v] = pre[v];
  for(auto to:g[v]) {
    if (pre[to] == -1) {
      low[v] = min(low[v], dfs(g, res, to, count, v, low, pre));
      if(low[to] == pre[to]) res.push_back(make_pair(v, to));
    } else {
      if(from == to) continue;
      low[v] = min(low[v], low[to]);
    }
  }
  return low[v];
}

vector<PL> bridges(VVL& g, ll N) {
  vector<PL> res;
  if (N > 0) {
    VL low(N, -1);
    VL pre(N, -1);
    ll count = 0;
    dfs(g, res, 0, count, -1, low, pre);
  }
  return res;
}

void solve() {
  ll N,A,B;
  cin >> N >> A >> B;
  ll ans = 0;
  VL X(N);
  REP(i, N) cin >> X[i];
  REP(i, N-1) ans += min((X[i+1]-X[i])*A, B);
  cout << ans << "\n";
}



int main() {
  // init
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}

Submission Info

Submission Time
Task D - Walk and Teleport
User gahou
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1908 Byte
Status AC
Exec Time 11 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 15
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_balancedmax_01.txt, subtask_1_balancedmax_02.txt, subtask_1_max_01.txt, subtask_1_max_02.txt, subtask_1_min_01.txt, subtask_1_onlya_01.txt, subtask_1_onlyamax_01.txt, subtask_1_onlyb_01.txt, subtask_1_onlybmax_01.txt, subtask_1_rand_01.txt, subtask_1_rand_02.txt, subtask_1_rand_03.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_balancedmax_01.txt AC 11 ms 1024 KB
subtask_1_balancedmax_02.txt AC 11 ms 1024 KB
subtask_1_max_01.txt AC 11 ms 1024 KB
subtask_1_max_02.txt AC 11 ms 1024 KB
subtask_1_min_01.txt AC 1 ms 256 KB
subtask_1_onlya_01.txt AC 6 ms 640 KB
subtask_1_onlyamax_01.txt AC 11 ms 1024 KB
subtask_1_onlyb_01.txt AC 4 ms 384 KB
subtask_1_onlybmax_01.txt AC 11 ms 1024 KB
subtask_1_rand_01.txt AC 8 ms 768 KB
subtask_1_rand_02.txt AC 10 ms 896 KB
subtask_1_rand_03.txt AC 5 ms 512 KB