結果
問題 |
No.1071 ベホマラー
|
ユーザー |
![]() |
提出日時 | 2020-06-19 03:56:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 829 bytes |
コンパイル時間 | 1,186 ms |
コンパイル使用メモリ | 101,064 KB |
最終ジャッジ日時 | 2025-01-11 05:22:53 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 6 TLE * 14 |
ソースコード
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<cmath> #include<queue> #include<stack> #include<list> #define endl "\n" using namespace std; using ll = long long; const ll MOD = 1e9+7; const ll INF = 1e18; #define REP(i, n) for(int i = 0; i < n; i++) using Graph = vector<vector<int>>; int main(){ ll n,k,x,y; cin>>n>>k>>x>>y; vector<ll> a(n); ll tmp = 0; for(ll i=0;i<n;i++){ cin>>a[i]; if(a[i] == 1) tmp++; } sort(a.begin(),a.end()); if(a[n-1] == 1){ cout<<0<<endl; return 0; } ll ans = 0; for(ll i=0;i<(a[n-1]-1+k-1)/k;i++){ ans += min( (n-tmp)*x, y); while(i == (a[tmp]-1+k-1)/k-1){ tmp++; } // cout<<ans<<" "<<n-tmp<<endl; } cout<<ans<<endl; }