結果
| 問題 |
No.31 悪のミックスジュース
|
| コンテスト | |
| ユーザー |
しらっ亭
|
| 提出日時 | 2016-05-20 00:04:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,321 bytes |
| コンパイル時間 | 1,929 ms |
| コンパイル使用メモリ | 176,064 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-06 11:06:57 |
| 合計ジャッジ時間 | 2,828 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 WA * 8 |
ソースコード
#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; }
しらっ亭