結果
問題 |
No.31 悪のミックスジュース
|
ユーザー |
|
提出日時 | 2015-01-28 17:18:14 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 703 bytes |
コンパイル時間 | 797 ms |
コンパイル使用メモリ | 63,428 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 03:37:27 |
合計ジャッジ時間 | 1,310 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 8 WA * 9 |
ソースコード
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <utility> using namespace std; int main() { int n, v, c; cin >> n >> v; vector<long long> sum(n + 1, 0); vector<double> cost_v(n + 1, 0.0); for (int i = 1; i <= n; i++) { cin >> c; sum[i] += sum[i - 1] + c; cost_v[i] = 1.0 * sum[i] / i; } long long ans = 0; ans += sum[n]; v -= n; while (v > 0) { int limit = min(n, v); double min_cost = cost_v[1]; int min_pos = 1; for (int i = 2; i <= limit; i++) { if (min_cost > cost_v[i]) { min_cost = cost_v[i]; min_pos = i; } } ans += (long long) v / min_pos * sum[min_pos]; v %= min_pos; } cout << ans << endl; return 0; }