結果

問題 No.31 悪のミックスジュース
ユーザー しらっ亭しらっ亭
提出日時 2016-05-20 00:04:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,321 bytes
コンパイル時間 1,836 ms
コンパイル使用メモリ 170,744 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 01:42:44
合計ジャッジ時間 2,706 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FORR(x,arr) for(auto&& x:arr)
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
typedef long long ll;
// -------------------------------------

template<class T> inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
typedef pair<double, int> DI;

int N, V;
ll C[100];

void Main() {
  scanf("%d %d", &N, &V);

  vector<DI> v_ci(N);
  REP(i, N) {
    scanf("%lld", C+i);
    if (i) C[i] += C[i-1];
    v_ci[i] = {1.0 * C[i] / (i+1), i};
  }

  ll ans = C[N-1];
  V -= N;
  if (V <= 0) {
    _P("%lld\n", ans);
    return;
  }

  sort(ALL(v_ci));

  int mi = v_ci[0].second;
  int mv = mi + 1;

  int x = V / mv;
  if (x) {
    V -= (x - 1) * mv;
    ans += (x - 1) * C[mi];
  }

  vector<ll> dp(V+1, 1e18 + 1);
  dp[0] = ans;

  REP(i, V) if (dp[i] > 0) {
    REP(j, N) if (i+j+1 <= V) {
      amin(dp[i + j + 1], dp[i] + C[j]);
    }
  }
  _P("%lld\n", dp[V]);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }
0