結果

問題 No.409 ダイエット
ユーザー okadukiokaduki
提出日時 2016-08-07 01:33:33
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,351 bytes
コンパイル時間 1,740 ms
コンパイル使用メモリ 158,432 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2024-04-24 19:42:08
合計ジャッジ時間 6,900 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
11,136 KB
testcase_01 AC 3 ms
5,760 KB
testcase_02 AC 3 ms
5,888 KB
testcase_03 AC 3 ms
5,760 KB
testcase_04 AC 3 ms
5,760 KB
testcase_05 AC 3 ms
5,760 KB
testcase_06 AC 3 ms
5,888 KB
testcase_07 AC 2 ms
5,760 KB
testcase_08 AC 3 ms
5,632 KB
testcase_09 AC 3 ms
5,632 KB
testcase_10 AC 3 ms
5,632 KB
testcase_11 AC 3 ms
5,888 KB
testcase_12 AC 3 ms
5,760 KB
testcase_13 AC 3 ms
5,760 KB
testcase_14 AC 3 ms
5,760 KB
testcase_15 AC 3 ms
5,760 KB
testcase_16 AC 3 ms
5,760 KB
testcase_17 AC 3 ms
5,760 KB
testcase_18 AC 3 ms
5,760 KB
testcase_19 AC 3 ms
5,888 KB
testcase_20 AC 3 ms
5,888 KB
testcase_21 AC 4 ms
5,760 KB
testcase_22 AC 4 ms
5,760 KB
testcase_23 AC 3 ms
5,760 KB
testcase_24 AC 3 ms
5,760 KB
testcase_25 AC 3 ms
5,760 KB
testcase_26 AC 3 ms
5,760 KB
testcase_27 AC 3 ms
5,632 KB
testcase_28 AC 3 ms
5,760 KB
testcase_29 AC 3 ms
5,888 KB
testcase_30 AC 3 ms
5,760 KB
testcase_31 AC 3 ms
5,760 KB
testcase_32 AC 3 ms
5,760 KB
testcase_33 AC 3 ms
5,632 KB
testcase_34 AC 3 ms
5,760 KB
testcase_35 AC 4 ms
5,760 KB
testcase_36 AC 3 ms
5,760 KB
testcase_37 AC 3 ms
5,760 KB
testcase_38 AC 3 ms
5,760 KB
testcase_39 AC 3 ms
5,760 KB
testcase_40 AC 3 ms
5,760 KB
testcase_41 AC 3 ms
5,760 KB
testcase_42 AC 4 ms
5,632 KB
testcase_43 AC 4 ms
5,760 KB
testcase_44 AC 3 ms
5,760 KB
testcase_45 AC 3 ms
5,760 KB
testcase_46 AC 4 ms
5,760 KB
testcase_47 AC 4 ms
5,760 KB
testcase_48 AC 3 ms
5,760 KB
testcase_49 AC 3 ms
5,760 KB
testcase_50 AC 4 ms
5,760 KB
testcase_51 AC 4 ms
5,760 KB
testcase_52 AC 3 ms
5,760 KB
testcase_53 AC 4 ms
5,760 KB
testcase_54 AC 3 ms
5,760 KB
testcase_55 AC 14 ms
6,656 KB
testcase_56 TLE -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

const int MAX = 300010;
LL N, A, B, W;
LL dp[MAX];
LL xs[MAX];
LL f(LL x){
  return -x*A + x*(x+1)/2 * B;
}
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  cin >> N >> A >> B >> W;
  REP(i,N) cin >> xs[i];

  fill(dp, dp+MAX, 1e15);
  int R = N;
  dp[N] = W;
  for(int i=N-1;i>=0;--i){
	for(int j=R;j>=i+1;--j){
	  LL nxt = xs[i]+f(j-i-1)+dp[j];
	  if(nxt < dp[i]){
		dp[i] = nxt;
		R = j;
	  }
	}
  }

  LL ans = 1e15;
  REP(i,N+1) ans = min(ans, f(i)+dp[i]);
  cout << ans << endl;

  return 0;
}
0