結果
| 問題 | No.31 悪のミックスジュース |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-01-19 04:50:38 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,049 bytes |
| 記録 | |
| コンパイル時間 | 3,824 ms |
| コンパイル使用メモリ | 355,484 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-01-19 04:50:44 |
| 合計ジャッジ時間 | 4,750 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 13 |
ソースコード
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
void solve(){
ll N,V; cin>>N>>V;
vector<ll> C(N);
for(auto&x:C)cin>>x;
ll ANS=accumulate(begin(C),end(C),0LL);
if(V<=N){
cout<<ANS;
return;
}
V-=N;
vector<ll> pref(N);
partial_sum(begin(C),end(C),begin(pref));
const int U=10010;
vector<ll> dp(U,1e10);
dp[0]=0;
for(int i=1;i<=N;++i){
for(int j=i;j<U;++j){
ll cst=dp[j-i]+pref[i-1];
if(dp[j]>cst)dp[j]=cst;
}
}
vector<double> min_rate(N);
for(int i=0;i<N;++i)min_rate[i]=(pref[i]*1.)/(i+1);
const int n=min_element(begin(min_rate),end(min_rate))-begin(min_rate)+1;
ll k=0;
if(V>U)k=(V-U+n-1)/n;
ANS+=k*pref[n-1];
ANS+=dp[V-k*n];
cout<<ANS;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(nullptr);
int T=1; // cin>>T;
while(T--)solve();
cout<<endl;
return 0;
}