結果
| 問題 |
No.31 悪のミックスジュース
|
| コンテスト | |
| ユーザー |
jell
|
| 提出日時 | 2019-07-11 15:45:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 5,000 ms |
| コード長 | 969 bytes |
| コンパイル時間 | 1,766 ms |
| コンパイル使用メモリ | 172,628 KB |
| 実行使用メモリ | 7,296 KB |
| 最終ジャッジ日時 | 2024-11-07 19:45:41 |
| 合計ジャッジ時間 | 2,775 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
using pll = pair<i64,i64>;
#define fir first
#define sec second
void ios_untie() {
ios::sync_with_stdio(false);
cin.tie(0);
}
i64 c[128];
i64 n,V;
i64 dp[1010101];
pll d[128];
signed main() {
ios_untie();
cin>>n>>V;
V-=n;
if(V<0) V=0;
const int capmx=min(V,n*(n-1)*(n-1)/2);
for(int i=1; i<=n; ++i) cin>>c[i];
for(int i=1; i<n; ++i) c[i+1]+=c[i];
for(int i=1; i<=n; ++i) d[i-1]={i,c[i]};
sort(d,d+n,[](pll a,pll b)->bool{return a.fir*b.sec>a.sec*b.fir;});
fill(dp,dp+capmx+1,1e18);
cerr<<d[0].fir<<" "<<d[0].sec<<endl;
dp[0]=0;
for(int i=1; i<n; ++i) {
i64 z,y; tie(y,z)=d[i];
for(int j=0; j+y<=capmx; ++j) {
dp[j+y]=min(dp[j+y],dp[j]+z);
}
}
i64 ans=1e18;
for(int w=0; w<=capmx; ++w) {
ans=min(ans,dp[w]+(V-w-1+d[0].fir)/d[0].fir*d[0].sec);
}
cout<<ans+c[n]<<endl;
}
jell