結果
| 問題 |
No.31 悪のミックスジュース
|
| コンテスト | |
| ユーザー |
izuru_matsuura
|
| 提出日時 | 2016-02-16 21:31:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,318 bytes |
| コンパイル時間 | 1,293 ms |
| コンパイル使用メモリ | 163,064 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 07:18:51 |
| 合計ジャッジ時間 | 2,038 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 11 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
namespace {
typedef double real;
typedef long long ll;
template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
if (vs.empty()) return os << "[]";
os << "[" << vs[0];
for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
return os << "]";
}
int N;
ll V;
vector<ll> C;
void input() {
cin >> N >> V;
C.resize(N);
for (int i = 0; i < N; i++) cin >> C[i];
}
void solve() {
vector<real> S(N, 0); // [0, k)を1[L]ずつまぜたジュースのk[L]の値段
S[0] = C[0];
for (int i = 1; i < N; i++) {
S[i] = S[i - 1] + C[i];
}
ll ans = S[N - 1];
V -= N;
for (int k = N - 1; V > 0; ) {
int j = k;
real c = S[k] / (k + 1);
for (int i = 0; i < k; i++) {
if (S[i] / (i + 1) < c) {
j = i;
c = S[i] / (i + 1);
}
}
ll x = V / (j + 1);
ans += x * S[j];
V -= x * (j + 1);
k = j - 1;
//cerr << k << " " << x << endl;
}
cout << ans << endl;
}
}
int main() {
input(); solve();
return 0;
}
izuru_matsuura