結果
問題 | No.409 ダイエット |
ユーザー | 🍡yurahuna |
提出日時 | 2017-01-08 19:17:35 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,350 bytes |
コンパイル時間 | 1,729 ms |
コンパイル使用メモリ | 167,632 KB |
実行使用メモリ | 10,400 KB |
最終ジャッジ日時 | 2024-05-09 23:31:23 |
合計ジャッジ時間 | 6,639 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
7,516 KB |
testcase_01 | AC | 2 ms
7,644 KB |
testcase_02 | AC | 2 ms
7,520 KB |
testcase_03 | AC | 3 ms
7,520 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 3 ms
7,520 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 3 ms
7,520 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 3 ms
7,520 KB |
testcase_16 | AC | 3 ms
7,396 KB |
testcase_17 | WA | - |
testcase_18 | AC | 2 ms
7,652 KB |
testcase_19 | AC | 3 ms
7,520 KB |
testcase_20 | AC | 2 ms
7,520 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 3 ms
7,520 KB |
testcase_24 | AC | 3 ms
7,520 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 3 ms
7,520 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 3 ms
7,524 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 2 ms
7,644 KB |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | AC | 26 ms
8,260 KB |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
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 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
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 | - |
コンパイルメッセージ
main.cpp:59:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 59 | main() { | ^~~~
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long // <-----!!!!!!!!!!!!!!!!!!! #define rep(i,n) for (int i=0;i<(n);++i) #define rep2(i,a,b) for (int i=(a);i<(b);++i) #define rrep(i,n) for (int i=(n)-1;i>=0;--i) #define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i) #define chmin(a,b) (a)=min((a),(b)); #define chmax(a,b) (a)=max((a),(b)); #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define printV(_v) cout<<(#_v)<<":";for(auto(_x):(_v)){cout<<" "<<(_x);}cout<<endl; #define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;} #define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;} #define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl; #define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;} inline void output(){ cout << endl; } template<typename First, typename... Rest> inline void output(const First& first, const Rest&... rest) { cout << first << " "; output(rest...); } using ll = long long; using Pii = pair<int, int>; using TUPLE = tuple<int, int, int>; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; const int inf = 1ll << 60; const int mod = 1e9 + 7; using Graph = vector<vector<int>>; int N, A, B, W; int D[300010]; int deq[300010]; int dp[300010]; int a(int i) { return - i * B; } int b(int i) { return dp[i] + i * A + i * (i + 1) * B / 2; } int f(int i, int x) { return a(i) * x + b(i); } bool check(int f1, int f2, int f3) { int a1 = a(f1), b1 = b(f1); int a2 = a(f2), b2 = b(f2); int a3 = a(f3), b3 = b(f3); return (a2 - a1) * (b3 - b2) >= (b2 - b1) * (a3 - a2); } main() { std::ios::sync_with_stdio(false); std::cin.tie(0); cin >> N >> A >> B >> W; rep(i, N) cin >> D[i]; int s = 0, t = 1; deq[0] = 0; fill(dp, dp + N + 1, inf); dp[0] = W; rep2(i, 1, N + 1) { while (s + 1 < t && f(deq[s], i - 1) >= f(deq[s + 1], i - 1)) s++; dp[i] = D[i - 1] - (i - 1) * A + i * (i - 1) * B / 2 + f(deq[s], i); while (s + 1 < t && check(deq[t - 2], deq[t - 1], i)) t--; deq[t++] = i; } int ans = inf; rep(i, N + 1) { chmin(ans, dp[i] - (N - i) * A + (N - i) * (N - i + 1) * B / 2); } cout << ans << endl; }