mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:11:58 +00:00
parent
c1db271f6b
commit
262d2c01f9
48
AtCoder/ABC246/C/C.cpp
Normal file
48
AtCoder/ABC246/C/C.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 2e5 + 5;
|
||||
|
||||
int n, k, x, a[N];
|
||||
long long sum;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
|
||||
cin >> n >> k >> x;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
sum += a[i];
|
||||
}
|
||||
|
||||
std::sort(a + 1, a + 1 + n, std::greater<int>());
|
||||
for (int i = 1, t; i <= n; i++) {
|
||||
if (a[i] < x) break;
|
||||
|
||||
t = a[i] / x;
|
||||
a[i] %= x;
|
||||
|
||||
if (k > t) {
|
||||
k -= t;
|
||||
sum -= t * x;
|
||||
} else {
|
||||
sum -= k * x;
|
||||
cout << sum << endl;
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(a + 1, a + 1 + n, std::greater<int>());
|
||||
for (int i = 1; i <= std::min(n, k); i++) {
|
||||
sum -= a[i];
|
||||
}
|
||||
|
||||
cout << sum << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user