結果
問題 | No.409 ダイエット |
ユーザー | vjudge1 |
提出日時 | 2024-11-12 18:53:22 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,158 bytes |
コンパイル時間 | 1,788 ms |
コンパイル使用メモリ | 169,356 KB |
実行使用メモリ | 35,584 KB |
最終ジャッジ日時 | 2024-11-12 18:53:28 |
合計ジャッジ時間 | 5,993 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 8 ms
28,100 KB |
testcase_01 | AC | 8 ms
30,144 KB |
testcase_02 | AC | 7 ms
28,228 KB |
testcase_03 | AC | 7 ms
28,104 KB |
testcase_04 | AC | 8 ms
30,148 KB |
testcase_05 | AC | 8 ms
30,276 KB |
testcase_06 | AC | 8 ms
28,224 KB |
testcase_07 | AC | 7 ms
28,232 KB |
testcase_08 | AC | 7 ms
28,228 KB |
testcase_09 | AC | 8 ms
28,228 KB |
testcase_10 | AC | 7 ms
30,144 KB |
testcase_11 | AC | 7 ms
28,096 KB |
testcase_12 | AC | 7 ms
28,104 KB |
testcase_13 | AC | 8 ms
28,104 KB |
testcase_14 | AC | 8 ms
28,228 KB |
testcase_15 | AC | 7 ms
28,100 KB |
testcase_16 | AC | 8 ms
28,228 KB |
testcase_17 | AC | 8 ms
27,968 KB |
testcase_18 | AC | 7 ms
28,100 KB |
testcase_19 | AC | 8 ms
28,228 KB |
testcase_20 | AC | 8 ms
30,152 KB |
testcase_21 | AC | 8 ms
28,224 KB |
testcase_22 | AC | 8 ms
27,972 KB |
testcase_23 | AC | 8 ms
28,228 KB |
testcase_24 | AC | 8 ms
27,976 KB |
testcase_25 | AC | 7 ms
28,096 KB |
testcase_26 | AC | 8 ms
28,096 KB |
testcase_27 | AC | 8 ms
30,016 KB |
testcase_28 | AC | 8 ms
28,104 KB |
testcase_29 | AC | 8 ms
28,224 KB |
testcase_30 | AC | 7 ms
28,100 KB |
testcase_31 | AC | 8 ms
28,100 KB |
testcase_32 | AC | 8 ms
28,228 KB |
testcase_33 | AC | 8 ms
28,100 KB |
testcase_34 | AC | 8 ms
30,148 KB |
testcase_35 | AC | 8 ms
28,096 KB |
testcase_36 | AC | 8 ms
28,100 KB |
testcase_37 | AC | 8 ms
30,148 KB |
testcase_38 | AC | 8 ms
28,100 KB |
testcase_39 | AC | 8 ms
28,100 KB |
testcase_40 | AC | 8 ms
28,096 KB |
testcase_41 | AC | 8 ms
28,100 KB |
testcase_42 | AC | 8 ms
30,144 KB |
testcase_43 | AC | 8 ms
28,100 KB |
testcase_44 | AC | 7 ms
28,100 KB |
testcase_45 | AC | 8 ms
28,100 KB |
testcase_46 | AC | 8 ms
28,100 KB |
testcase_47 | AC | 8 ms
28,228 KB |
testcase_48 | AC | 8 ms
28,100 KB |
testcase_49 | AC | 8 ms
28,104 KB |
testcase_50 | AC | 8 ms
27,972 KB |
testcase_51 | AC | 8 ms
28,224 KB |
testcase_52 | AC | 7 ms
28,096 KB |
testcase_53 | AC | 8 ms
28,104 KB |
testcase_54 | AC | 8 ms
28,100 KB |
testcase_55 | AC | 16 ms
30,920 KB |
testcase_56 | AC | 24 ms
30,288 KB |
testcase_57 | AC | 24 ms
35,340 KB |
testcase_58 | AC | 14 ms
30,916 KB |
testcase_59 | AC | 18 ms
30,788 KB |
testcase_60 | AC | 12 ms
32,404 KB |
testcase_61 | AC | 21 ms
35,580 KB |
testcase_62 | AC | 21 ms
32,804 KB |
testcase_63 | AC | 22 ms
35,584 KB |
testcase_64 | AC | 15 ms
32,496 KB |
testcase_65 | AC | 25 ms
32,392 KB |
testcase_66 | AC | 23 ms
33,740 KB |
testcase_67 | AC | 18 ms
32,592 KB |
testcase_68 | AC | 20 ms
32,824 KB |
testcase_69 | AC | 21 ms
31,304 KB |
testcase_70 | AC | 24 ms
35,548 KB |
testcase_71 | AC | 17 ms
32,328 KB |
testcase_72 | AC | 26 ms
35,400 KB |
testcase_73 | AC | 27 ms
32,268 KB |
testcase_74 | AC | 18 ms
32,444 KB |
testcase_75 | AC | 26 ms
31,304 KB |
testcase_76 | AC | 19 ms
31,428 KB |
testcase_77 | AC | 17 ms
30,540 KB |
testcase_78 | AC | 16 ms
32,768 KB |
testcase_79 | AC | 15 ms
30,912 KB |
testcase_80 | WA | - |
testcase_81 | AC | 26 ms
32,844 KB |
testcase_82 | AC | 19 ms
31,300 KB |
testcase_83 | AC | 22 ms
33,072 KB |
testcase_84 | AC | 19 ms
30,536 KB |
testcase_85 | AC | 9 ms
28,104 KB |
testcase_86 | AC | 19 ms
32,516 KB |
testcase_87 | AC | 22 ms
31,692 KB |
testcase_88 | AC | 14 ms
30,532 KB |
testcase_89 | AC | 21 ms
30,272 KB |
testcase_90 | AC | 14 ms
30,280 KB |
testcase_91 | AC | 23 ms
30,284 KB |
ソースコード
#include<bits/stdc++.h> #define int long long using namespace std; inline int read() { register int x=0,f=0;register char c=getchar(); while(c<'0'||c>'9')f=(c=='-'),c=getchar(); while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c&15),c=getchar(); return f?-x:x; } const int MAXN=3e6; int n,a,b,w,d[MAXN],dp[MAXN]; long double Y(int i){ return (long double)(dp[i]+i*a+1.0*b*(i*i+i)/2); } long double X(int i){ return (long double)1.0*i; } long double K(int j1,int j2){ return (long double)1.0*(Y(j1)-Y(j2))/(X(j1)-X(j2)); } int q[MAXN],head,tail; signed main() { // freopen("chips.in","r",stdin); // freopen("chips.out","w",stdout); memset(dp,0x3f,sizeof dp); n=read();a=read();b=read();w=read(); for(int i=1;i<=n;i++)d[i]=read(); dp[0]=w; head=1;tail=1;q[1]=0; for(int i=1;i<=n;i++){ while(head<tail && (long double)K(q[head],q[head+1])<(long double)1.0*i*b)head++; int j=q[head]; dp[i]=dp[j]-(i-j-1)*a+d[i]+b*(i-j-1)*(i-j)/2; while(head<tail && (long double)K(q[tail],i)<(long double)K(q[tail],q[tail-1]) )tail--; q[++tail]=i; } int ans=1e18; for(int i=n;i>=0;i--){ ans=min(ans,dp[i]-(n-i)*a+b*(n-i+1)*(n-i)/2); } cout<<ans; return 0; }