結果
問題 | No.409 ダイエット |
ユーザー | vjudge1 |
提出日時 | 2024-11-12 18:49:31 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,160 bytes |
コンパイル時間 | 1,999 ms |
コンパイル使用メモリ | 167,980 KB |
実行使用メモリ | 31,232 KB |
最終ジャッジ日時 | 2024-11-12 18:49:38 |
合計ジャッジ時間 | 6,584 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 12 ms
26,880 KB |
testcase_01 | AC | 13 ms
26,880 KB |
testcase_02 | AC | 12 ms
26,880 KB |
testcase_03 | AC | 12 ms
27,008 KB |
testcase_04 | AC | 13 ms
27,008 KB |
testcase_05 | AC | 12 ms
26,880 KB |
testcase_06 | AC | 8 ms
26,880 KB |
testcase_07 | AC | 8 ms
27,008 KB |
testcase_08 | AC | 7 ms
26,752 KB |
testcase_09 | AC | 8 ms
26,880 KB |
testcase_10 | AC | 8 ms
26,880 KB |
testcase_11 | AC | 8 ms
27,008 KB |
testcase_12 | AC | 8 ms
27,008 KB |
testcase_13 | AC | 8 ms
26,880 KB |
testcase_14 | AC | 8 ms
27,008 KB |
testcase_15 | AC | 8 ms
26,880 KB |
testcase_16 | AC | 8 ms
27,008 KB |
testcase_17 | AC | 8 ms
26,880 KB |
testcase_18 | AC | 8 ms
26,752 KB |
testcase_19 | AC | 8 ms
27,008 KB |
testcase_20 | AC | 8 ms
27,008 KB |
testcase_21 | AC | 19 ms
27,008 KB |
testcase_22 | AC | 7 ms
26,880 KB |
testcase_23 | AC | 8 ms
27,008 KB |
testcase_24 | AC | 7 ms
26,880 KB |
testcase_25 | AC | 7 ms
26,880 KB |
testcase_26 | AC | 8 ms
27,008 KB |
testcase_27 | AC | 8 ms
26,880 KB |
testcase_28 | AC | 20 ms
27,008 KB |
testcase_29 | AC | 8 ms
26,880 KB |
testcase_30 | AC | 8 ms
27,008 KB |
testcase_31 | AC | 7 ms
27,008 KB |
testcase_32 | AC | 8 ms
26,880 KB |
testcase_33 | AC | 7 ms
27,008 KB |
testcase_34 | AC | 8 ms
27,008 KB |
testcase_35 | AC | 8 ms
27,136 KB |
testcase_36 | AC | 9 ms
27,008 KB |
testcase_37 | AC | 8 ms
27,008 KB |
testcase_38 | AC | 8 ms
27,008 KB |
testcase_39 | AC | 8 ms
27,008 KB |
testcase_40 | AC | 7 ms
27,136 KB |
testcase_41 | AC | 9 ms
27,136 KB |
testcase_42 | AC | 8 ms
27,136 KB |
testcase_43 | AC | 7 ms
27,008 KB |
testcase_44 | AC | 8 ms
27,008 KB |
testcase_45 | AC | 13 ms
27,136 KB |
testcase_46 | AC | 13 ms
27,136 KB |
testcase_47 | AC | 12 ms
27,008 KB |
testcase_48 | AC | 12 ms
27,008 KB |
testcase_49 | AC | 12 ms
27,008 KB |
testcase_50 | AC | 13 ms
27,008 KB |
testcase_51 | AC | 12 ms
27,008 KB |
testcase_52 | AC | 13 ms
27,136 KB |
testcase_53 | AC | 13 ms
27,136 KB |
testcase_54 | AC | 12 ms
27,008 KB |
testcase_55 | AC | 20 ms
28,800 KB |
testcase_56 | AC | 30 ms
29,184 KB |
testcase_57 | AC | 29 ms
31,104 KB |
testcase_58 | AC | 18 ms
28,672 KB |
testcase_59 | AC | 22 ms
29,184 KB |
testcase_60 | AC | 18 ms
28,672 KB |
testcase_61 | AC | 26 ms
30,464 KB |
testcase_62 | AC | 26 ms
30,976 KB |
testcase_63 | AC | 26 ms
30,464 KB |
testcase_64 | AC | 20 ms
28,672 KB |
testcase_65 | AC | 28 ms
29,952 KB |
testcase_66 | AC | 28 ms
30,720 KB |
testcase_67 | AC | 22 ms
30,208 KB |
testcase_68 | AC | 23 ms
29,184 KB |
testcase_69 | AC | 34 ms
30,208 KB |
testcase_70 | AC | 28 ms
30,336 KB |
testcase_71 | AC | 20 ms
28,800 KB |
testcase_72 | AC | 31 ms
31,232 KB |
testcase_73 | AC | 32 ms
30,208 KB |
testcase_74 | AC | 24 ms
29,568 KB |
testcase_75 | AC | 31 ms
30,208 KB |
testcase_76 | AC | 23 ms
29,824 KB |
testcase_77 | AC | 23 ms
28,416 KB |
testcase_78 | AC | 21 ms
29,184 KB |
testcase_79 | AC | 19 ms
28,544 KB |
testcase_80 | WA | - |
testcase_81 | AC | 31 ms
30,208 KB |
testcase_82 | AC | 25 ms
29,696 KB |
testcase_83 | AC | 26 ms
29,952 KB |
testcase_84 | AC | 25 ms
28,928 KB |
testcase_85 | AC | 13 ms
27,136 KB |
testcase_86 | AC | 25 ms
28,928 KB |
testcase_87 | AC | 28 ms
30,464 KB |
testcase_88 | AC | 19 ms
28,032 KB |
testcase_89 | AC | 26 ms
28,672 KB |
testcase_90 | AC | 18 ms
27,776 KB |
testcase_91 | AC | 28 ms
28,928 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; }