結果
問題 | No.409 ダイエット |
ユーザー | vjudge1 |
提出日時 | 2024-11-12 18:54:04 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,159 bytes |
コンパイル時間 | 1,665 ms |
コンパイル使用メモリ | 168,964 KB |
実行使用メモリ | 35,576 KB |
最終ジャッジ日時 | 2024-11-12 18:54:10 |
合計ジャッジ時間 | 5,103 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 7 ms
28,100 KB |
testcase_01 | AC | 7 ms
27,972 KB |
testcase_02 | AC | 7 ms
30,272 KB |
testcase_03 | AC | 7 ms
28,100 KB |
testcase_04 | AC | 7 ms
30,152 KB |
testcase_05 | AC | 7 ms
30,148 KB |
testcase_06 | AC | 6 ms
28,100 KB |
testcase_07 | AC | 7 ms
28,100 KB |
testcase_08 | AC | 7 ms
28,224 KB |
testcase_09 | AC | 8 ms
28,224 KB |
testcase_10 | AC | 6 ms
28,100 KB |
testcase_11 | AC | 6 ms
28,100 KB |
testcase_12 | AC | 7 ms
28,228 KB |
testcase_13 | AC | 7 ms
28,100 KB |
testcase_14 | AC | 7 ms
28,228 KB |
testcase_15 | AC | 7 ms
28,100 KB |
testcase_16 | AC | 7 ms
28,104 KB |
testcase_17 | AC | 6 ms
28,100 KB |
testcase_18 | AC | 7 ms
28,096 KB |
testcase_19 | AC | 6 ms
28,100 KB |
testcase_20 | AC | 7 ms
28,232 KB |
testcase_21 | AC | 7 ms
28,228 KB |
testcase_22 | AC | 6 ms
27,968 KB |
testcase_23 | AC | 6 ms
28,100 KB |
testcase_24 | AC | 6 ms
28,228 KB |
testcase_25 | AC | 5 ms
28,228 KB |
testcase_26 | AC | 8 ms
28,100 KB |
testcase_27 | AC | 6 ms
28,104 KB |
testcase_28 | AC | 6 ms
28,232 KB |
testcase_29 | AC | 7 ms
27,976 KB |
testcase_30 | AC | 6 ms
28,228 KB |
testcase_31 | AC | 7 ms
30,148 KB |
testcase_32 | AC | 7 ms
28,232 KB |
testcase_33 | AC | 6 ms
27,972 KB |
testcase_34 | AC | 6 ms
28,100 KB |
testcase_35 | AC | 7 ms
28,224 KB |
testcase_36 | AC | 7 ms
28,104 KB |
testcase_37 | AC | 7 ms
28,100 KB |
testcase_38 | AC | 7 ms
28,104 KB |
testcase_39 | AC | 7 ms
28,104 KB |
testcase_40 | AC | 7 ms
30,020 KB |
testcase_41 | AC | 7 ms
28,096 KB |
testcase_42 | AC | 8 ms
30,144 KB |
testcase_43 | AC | 7 ms
28,228 KB |
testcase_44 | AC | 7 ms
28,104 KB |
testcase_45 | AC | 7 ms
30,148 KB |
testcase_46 | AC | 7 ms
28,100 KB |
testcase_47 | AC | 6 ms
27,968 KB |
testcase_48 | AC | 6 ms
27,972 KB |
testcase_49 | AC | 7 ms
28,104 KB |
testcase_50 | AC | 7 ms
28,232 KB |
testcase_51 | AC | 7 ms
28,228 KB |
testcase_52 | AC | 6 ms
28,104 KB |
testcase_53 | AC | 7 ms
28,224 KB |
testcase_54 | AC | 7 ms
30,144 KB |
testcase_55 | AC | 13 ms
31,040 KB |
testcase_56 | AC | 21 ms
30,288 KB |
testcase_57 | AC | 20 ms
33,208 KB |
testcase_58 | AC | 12 ms
32,288 KB |
testcase_59 | AC | 16 ms
30,916 KB |
testcase_60 | AC | 11 ms
28,740 KB |
testcase_61 | AC | 20 ms
35,576 KB |
testcase_62 | AC | 18 ms
34,188 KB |
testcase_63 | AC | 19 ms
33,096 KB |
testcase_64 | AC | 13 ms
32,564 KB |
testcase_65 | AC | 20 ms
30,928 KB |
testcase_66 | AC | 18 ms
32,960 KB |
testcase_67 | AC | 17 ms
31,684 KB |
testcase_68 | AC | 16 ms
30,788 KB |
testcase_69 | AC | 18 ms
32,828 KB |
testcase_70 | AC | 20 ms
31,556 KB |
testcase_71 | AC | 14 ms
31,040 KB |
testcase_72 | AC | 22 ms
35,376 KB |
testcase_73 | AC | 25 ms
31,176 KB |
testcase_74 | AC | 17 ms
31,304 KB |
testcase_75 | AC | 25 ms
31,564 KB |
testcase_76 | AC | 17 ms
31,300 KB |
testcase_77 | AC | 15 ms
30,668 KB |
testcase_78 | AC | 14 ms
31,184 KB |
testcase_79 | AC | 13 ms
28,744 KB |
testcase_80 | WA | - |
testcase_81 | AC | 22 ms
32,492 KB |
testcase_82 | AC | 17 ms
31,296 KB |
testcase_83 | AC | 18 ms
33,032 KB |
testcase_84 | AC | 17 ms
30,668 KB |
testcase_85 | AC | 9 ms
28,100 KB |
testcase_86 | AC | 18 ms
30,792 KB |
testcase_87 | AC | 19 ms
31,824 KB |
testcase_88 | AC | 13 ms
30,532 KB |
testcase_89 | AC | 19 ms
30,276 KB |
testcase_90 | AC | 12 ms
28,224 KB |
testcase_91 | AC | 19 ms
30,404 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; }