結果

問題 No.31 悪のミックスジュース
ユーザー pyonthpyonth
提出日時 2020-09-18 18:40:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,028 bytes
コンパイル時間 2,262 ms
コンパイル使用メモリ 203,660 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-04 08:59:57
合計ジャッジ時間 3,286 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, v;
	cin >> n >> v;
	ll C[n];
	double c[n];
	priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> que;
	rep(i, n) {
		cin >> C[i];
		c[i] = C[i];
		if (i) c[i] += c[i - 1];
		double p = i + 1;
		que.push({c[i] / p, i + 1});
	}
	if (n >= v) {
		cout << c[n - 1] << endl;
		return 0;
	}
	ll ans = c[n - 1];
	v -= n;
	while (!que.empty()) {
		if (v <= 0) break;
		pair<double, int> q = que.top();
		que.pop();
		if (q.second > v) continue;
		ans += v / q.second * c[q.second - 1];
		v %= q.second;
	}

	cout << ans << endl;

	return 0;
}
0