結果

問題 No.409 ダイエット
ユーザー okadukiokaduki
提出日時 2016-08-17 16:50:51
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,367 bytes
コンパイル時間 1,388 ms
コンパイル使用メモリ 159,736 KB
実行使用メモリ 8,216 KB
最終ジャッジ日時 2024-04-25 08:23:00
合計ジャッジ時間 5,264 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
	  }
	  else break;
	}
  }

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

  return 0;
}
0