1 solutions
-
-1
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5 + 5; ll a[N], suff[N]; int main() { int n, d; ll p; cin >> n >> d >> p; for(int i=1;i<=n;++i) cin>>a[i]; sort(a + 1, a + n + 1, greater < ll>()); for (int i = n; i >= 1; i--) { suff[i] = suff[i + 1] + a[i]; } ll ans = suff[1]; for (ll k = 1; k <= (n + d - 1) / d + 1; k++) { ll c = k * d; ll cost = k * p; if (c < n) { cost += suff[c + 1]; } ans = min(ans, cost); } cout << ans << endl; return 0; }
- 1
Information
- ID
- 24348
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 9
- Tags
- (None)
- # Submissions
- 748
- Accepted
- 60
- Uploaded By