結果
問題 |
No.1071 ベホマラー
|
ユーザー |
👑 |
提出日時 | 2022-01-14 00:31:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 484 bytes |
コンパイル時間 | 695 ms |
コンパイル使用メモリ | 75,044 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-17 20:27:20 |
合計ジャッジ時間 | 2,235 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ long long n,k,x,y;cin>>n>>k>>x>>y; vector<long long> A(n+1); for(int i = 0; n > i; i++){ cin>>A[i];A[i]--; } int z = min(n,y/x); //残りz人以下になった時はベホイミが最適 sort(A.begin(),A.end(),greater<long long>()); long long ans = (A[z]+k-1)/k*y; for(int i = 0; z > i; i++){ ans += x*(((A[i]-((A[z]+k-1)/k*k))+k-1)/k); } cout << ans << endl; }