結果

問題 No.31 悪のミックスジュース
ユーザー lgswdnlgswdn
提出日時 2023-10-13 17:25:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,794 bytes
コンパイル時間 2,674 ms
コンパイル使用メモリ 199,512 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 17:25:25
合計ジャッジ時間 3,488 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 3 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 3 ms
4,352 KB
testcase_05 AC 4 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 3 ms
4,352 KB
testcase_08 AC 4 ms
4,352 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 3 ms
4,352 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//vanitas vanitatum et omnia
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128; 
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}      
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x)  {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x)  {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x)  {return (x==0?-1:__builtin_ctzll(x));}

#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii; 
typedef vector<int> vi;  
typedef vector<pii> vp; 
typedef tuple<int,int,int> tiii;
int read() {
  int x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
  return x*w;
}

const int N=105,inf=0x3f3f3f3f3f3f3f3f;
int n,a[N],V,f[N*N],ans;

signed main() {
  n=read(), V=read();
  rep(i,1,n) a[i]=read(), ans+=a[i], V--;
  if(V<=0) return printf("%lld\n",ans), 0;
  rep(i,1,n) a[i]+=a[i-1];
  memset(f,0x3f,sizeof(f)); f[0]=0;
  rep(i,1,n) {
    rep(j,i,n*n) chmin(f[j],f[j-i]+a[i]);
  }
  int rc=1, rs=a[1], res=inf;
  rep(i,1,n) if(a[i]*rc<rs*i) rc=i, rs=a[i];
  rep(i,1,n*n) if((V-i)%rc==0) 
    chmin(res,(V-i)/rc*rs+f[i]);
  printf("%lld\n",res+ans);
  return 0;
}
0