結果

問題 No.31 悪のミックスジュース
ユーザー krotonkroton
提出日時 2014-09-29 00:31:20
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 761 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 68,864 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-28 19:53:24
合計ジャッジ時間 1,475 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

bool func(pair<ll, int> a, pair<ll, int> b){
	if(a.first * b.second == b.first * a.second){
		return a.second > b.second;
	}
	if(a.first * b.second < b.first * a.second){
		return true;
	} else {
		return false;
	}
}

int main(){
	int N;
	ll V;
	cin >> N >> V;

	vector<ll> C(N);
	for(int i=0;i<N;i++)cin >> C[i];

	vector< pair<ll, int> > S(N);
	ll s = 0;
	for(int i=0;i<N;i++){
		s += C[i];
		S[i] = make_pair(s, i + 1);
	}

	sort(S.begin(), S.end(), func);

	ll  res = 0;
	ll  minC = S[0].first;
	int minP = S[0].second;

	res += s;
	V -= N;

	res += minC * (V / minP);

	V -= minP * (V / minP);
	for(int i=0;i<V;i++)res += C[i];

	cout << res << endl;
}
0