結果

問題 No.2659 Manga App
ユーザー lgswdnlgswdn
提出日時 2024-03-08 21:31:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,115 bytes
コンパイル時間 3,537 ms
コンパイル使用メモリ 202,952 KB
実行使用メモリ 35,044 KB
最終ジャッジ日時 2024-03-08 21:31:54
合計ジャッジ時間 5,057 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
35,012 KB
testcase_01 AC 9 ms
35,012 KB
testcase_02 AC 10 ms
35,012 KB
testcase_03 AC 9 ms
35,012 KB
testcase_04 AC 10 ms
35,012 KB
testcase_05 AC 9 ms
35,012 KB
testcase_06 AC 9 ms
35,012 KB
testcase_07 AC 9 ms
35,012 KB
testcase_08 WA -
testcase_09 AC 10 ms
35,012 KB
testcase_10 AC 55 ms
35,044 KB
testcase_11 AC 9 ms
35,012 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 66 ms
35,044 KB
testcase_33 AC 66 ms
35,044 KB
testcase_34 AC 35 ms
35,044 KB
testcase_35 AC 49 ms
35,044 KB
testcase_36 AC 54 ms
35,044 KB
testcase_37 AC 49 ms
35,044 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//Shirasu Azusa 2024.03
#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=2005,inf=0x3f3f3f3f3f3f3f3f;
int n,x,y,m,d,f[N][N],g[N],p[N],ans=inf,a[N];

int calc(int t) {
  return max(0ll,t%d-x);
}

signed main() {
  n=read()-1, x=read(), y=read(), m=read(), d=x+y;
  rep(i,1,n) a[i]=read();
  rep(i,1,n) {
    g[i]=g[i-1]+a[i], p[i]=p[i-1]; int z=calc(g[i]);
    if(z) g[i]+=y-z, p[i]++;
  }
  memset(f,0x3f,sizeof(f)); f[0][0]=0;
  rep(i,1,n) rep(j,0,p[i-1]) {
    int z=calc(p[i-1]-j*y);
    chmin(f[i][j],f[i-1][j]);
    if(z) chmin(f[i][j+1],f[i][j]+z);
  }
  rep(i,0,n) {
    int H=0, W=0;
    rep(j,i+1,n) {
      H+=a[j]; int z=calc(H);
      if(z) H-=z, W+=z;
    }
    if(W<=m) {
      int j=0, r=m-W;
      while(j<=p[i]&&f[i][j]<=r) j++; j--;
      r=H-min(H,r-f[i][j]); int z=calc(r);
      if(z) r+=y-z;
      chmin(ans,g[i]-j*y+r);
    }
  }
  printf("%lld\n",ans);
  return 0;
}
0