結果

問題 No.1071 ベホマラー
ユーザー kotatsugame
提出日時 2020-06-05 21:33:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 405 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 69,928 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-17 13:36:43
合計ジャッジ時間 2,169 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,K,X,Y;
long A[1<<17];
long LIM=2e18;
main()
{
	cin>>N>>K>>X>>Y;
	long S=0;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		S+=A[i]=(A[i]-1+K-1)/K;
	}
	long ans;
	if(S<=LIM/X)ans=S*X;
	else ans=LIM;
	sort(A,A+N);
	long pre=0;
	for(int i=0;i<N;i++)
	{
		S-=(A[i]-pre)*(N-i);
		pre=A[i];
		if(S<=LIM/X)ans=min(ans,S*X+A[i]*Y);
	}
	cout<<ans<<endl;
}
0