結果

問題 No.31 悪のミックスジュース
ユーザー 184184
提出日時 2014-10-02 20:51:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,418 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 71,268 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-28 20:07:32
合計ジャッジ時間 1,263 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>

using namespace std;

/*
正解してたら匿名でも問題投稿ができる(実現度さらにアップ)!!!
 
warning なのにCE? 
*/

unsigned long long cst[101];
int idx[101];
struct smallercost{
	bool operator()(const int &a, const int &b){
		if(cst[a]!=cst[b])return cst[a]<cst[b];
		return a<b;
	}
};
int main(){
	 
	unsigned long long n,v;scanf("%llu%llu",&n,&v);
	unsigned long long sc=0;
	for(int i=0;i<n;i++){
		scanf("%llu",&cst[i]);
		idx[i]=i;
		sc+=(unsigned long long)cst[i];
	}
	sort(idx,idx+n,smallercost());	
	
	unsigned long long csts[101]={(unsigned long long)cst[0]};
	int minidx=0;
	for(int i=1;i<n;i++)csts[i]=(unsigned long long)cst[i]+csts[i-1];
	double mincst=(double)1000000001*100,dcsts[101];
	for(int i=0;i<n;i++){
		dcsts[i]=(double)csts[i]/(i+1);	
		if(mincst>dcsts[i])mincst=dcsts[i],minidx=i;
	}
		
	v-=n;
	if(v<=0){
		printf("%llu\n",sc);return 0;
	}
	else if(idx[0]==0){
		printf("%llu\n",(unsigned long long)v*cst[0]+sc);return 0;
	}	
	
	unsigned long long minc=(unsigned long long)v*csts[0],mcs;
	for(int i=1;i<n;i++){
		if(dcsts[i]<dcsts[0]){
			mcs=v/(i+1)*csts[i];
			if(v%(i+1))mcs+=csts[v%(i+1)-1];
			if(minc>mcs)minc=mcs;
		}
	}
	
	printf("%llu\n",minc+sc);
	return 0;
} 
0