結果
| 問題 |
No.31 悪のミックスジュース
|
| コンテスト | |
| ユーザー |
しらっ亭
|
| 提出日時 | 2016-05-20 00:12:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,353 bytes |
| コンパイル時間 | 1,392 ms |
| コンパイル使用メモリ | 165,616 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-14 15:52:59 |
| 合計ジャッジ時間 | 2,043 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘void Main()’:
main.cpp:24:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | scanf("%d %d", &N, &V);
| ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:28:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf("%lld", C+i);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#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 > 100) {
V -= (x - 100) * mv;
ans += (x - 100) * C[mi];
}
const ll INF = 1e18+1;
vector<ll> dp(V+1, INF);
dp[0] = ans;
REP(i, V) if (dp[i] < INF) {
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; }
しらっ亭