結果
| 問題 |
No.1071 ベホマラー
|
| コンテスト | |
| ユーザー |
hipotaf
|
| 提出日時 | 2020-06-09 19:34:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 2,000 ms |
| コード長 | 1,147 bytes |
| コンパイル時間 | 890 ms |
| コンパイル使用メモリ | 72,164 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-01-02 14:23:21 |
| 合計ジャッジ時間 | 2,835 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
template <class T>
using grid = vector<vector<T>>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define input(...) __VA_ARGS__; in(__VA_ARGS__)
void print() {
std::cout << std::endl;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
std::cout << head << " ";
print(std::forward<Tail>(tail)...);
}
void in() { }
template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
cin >> head;
in(std::forward<Tail>(tail)...);
}
int main() {
ll input(n, k, x, y);
vector<ll> a(n);
REP(i, n) cin >> a[i];
REP(i, n) a[i]--;
sort(a.begin(), a.end());
ll woundeds = n;
while (woundeds * x >= y) woundeds -= 1;
ll all;
if (woundeds == n) all = 0;
else all = (a[n - woundeds - 1] + k - 1) / k;
ll ans = all * y;
REP(i, woundeds) {
ans += (((a[n - woundeds + i] - all * k) + k - 1) / k) * x;
}
print(ans);
}
hipotaf