fork download
  1. /// no time to waste
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. #define ll long long
  5. #define ld long double
  6. #define eb emplace_back
  7. #define ef emplace_front
  8. #define pii pair <int, int>
  9. #define pli pair <ll, int>
  10. #define pll pair <ll, ll>
  11. #define pci pair <char, int>
  12. #define pil pair <int, ll>
  13. #define pic pair <int, char>
  14. #define fi first
  15. #define se second
  16. #define all(ac) ac.begin(), ac.end()
  17. #define MASK(x) (1 << (x))
  18. #define ub(i, j) (((i) >> (j)) & 1)
  19. #define FBIT(x) (MASK(x) - 1)
  20. #define FLIP(x, y) (FBIT(x) ^ (y))
  21. #define bit_count(x) (int) (__builtin_popcount(x))
  22. #define bit_countll(x) (int) (__builtin_popcountll(x))
  23. #define ii make_pair
  24. #define int128 __int128_t
  25. #define SZ(x) ((int) x.size())
  26. #define multi 0
  27.  
  28. const int MX = 1e6 + 6;
  29. int n, b;
  30. int a[MX];
  31. ll dp[MX];
  32.  
  33. void solve() {
  34. cin >> n >> b;
  35. for(int i = 1; i <= n; i++) cin >> a[i];
  36.  
  37. sort(a + 1, a + n + 1, greater <int>());
  38.  
  39. b = 100 - b;
  40. for(int i = 1; i <= n; i++) {
  41. dp[i] = dp[i - 1] + a[i] / 100 * b;
  42. if(i >= 3) dp[i] = min(dp[i], dp[i - 3] + a[i - 2] + a[i - 1]);
  43. }
  44.  
  45. cout << dp[n];
  46. return;
  47. }
  48.  
  49. int32_t main() {
  50. ios::sync_with_stdio(false);
  51. cin.tie(0), cout.tie(0);
  52. #define task "tet"
  53. if(fopen(task".inp", "r")) {
  54. freopen(task".inp", "r", stdin);
  55. freopen(task".out", "w", stdout);
  56. }
  57.  
  58. int testcase = multi == 2 ? 1e9 : 1; if(multi == 1) cin >> testcase;
  59. while(testcase--) solve();
  60. return 0;
  61. }
Success #stdin #stdout 0.01s 5716KB
stdin
7 20
300 400 300 200 500 400 200
stdout
1640