結果

問題 No.1071 ベホマラー
ユーザー hotaka0213hotaka0213
提出日時 2020-06-07 09:40:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 577 bytes
コンパイル時間 729 ms
コンパイル使用メモリ 78,032 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-25 04:03:04
合計ジャッジ時間 2,671 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 39 ms
4,376 KB
testcase_11 AC 37 ms
4,376 KB
testcase_12 AC 26 ms
4,376 KB
testcase_13 AC 34 ms
4,376 KB
testcase_14 AC 42 ms
4,380 KB
testcase_15 AC 48 ms
4,380 KB
testcase_16 AC 46 ms
4,376 KB
testcase_17 AC 46 ms
4,376 KB
testcase_18 AC 46 ms
4,504 KB
testcase_19 AC 46 ms
4,380 KB
testcase_20 AC 43 ms
4,376 KB
testcase_21 AC 43 ms
4,380 KB
testcase_22 AC 43 ms
4,380 KB
testcase_23 AC 43 ms
4,380 KB
testcase_24 AC 46 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
int main(){
	unsigned N,K,X,Y;
	std::cin>>N>>K>>X>>Y;
	std::vector<unsigned> A(N);
	int hp;
	for (unsigned i=0;i<N;i++){
		std::cin>>hp;
		A[i]=(hp-1)/K;
		if((hp-1)%K!=0){
			A[i]++;
		}
	}
	unsigned long long UsedMp=0;
	std::sort(A.begin(),A.end(),std::greater<unsigned>());
	if(Y/X<N){
		hp=A[Y/X];
		UsedMp+=((unsigned long long)A[Y/X])*Y;
	}else{
		hp=0;
	}
	for(unsigned i=0;i<N;i++){
		if(A[i]<=(unsigned)hp)break;
		UsedMp+=(unsigned long long)(A[i]-hp)*X;
	}
	std::cout<<UsedMp;
	return 0;
}
0