• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Oct 29th, 2019 200 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <bits/stdc++.h>
2. #include <stdio.h>
3.
4. using namespace std;
5.
6. #define int long long
7.
8. void solve();
9.
10. signed main () {
11.     // cout << fixed << setprecision(1);
12.     ios_base::sync_with_stdio(false);
13.     cin.tie(0); cout.tie(0);
14.     #ifdef LOCAL
15.         freopen("input.txt", "r", stdin);
16.     #endif
17.     int t = 1;
18.     // cin >> t;
19.     int tt = t;
20.     while (t--) {
21.         solve();
22.     }
23.     return 0;
24. }
25. const int N = 8005;
26. int cnt[N] = {0};
27. int n, k;
28. void solve() {
29.     cin >> n >> k;
30.     for (int i = 1; i <= n; ++i) {
31.         int x;
32.         cin >> x;
33.         cnt[x]++;
34.     }
35.     sort(cnt + 1, cnt + k + 1);
36.     int mn = 1e18;
37.     for (int i = 0; i <= k; i += 2) {
38.         int mx = -1e18;
39.         int rides = 0;
40.         for (int j = 1; j <= i; j += 1) {
41.             mx = max(mx, cnt[j] + cnt[i - j + 1]);
42.             if (j < i  - j + 1)
43.                 ++rides;
44.         }
45.         for (int j = i + 1; j <= k; j += 1)
46.             mx = max(mx, cnt[j]), ++rides;
47.         mn = min(mn, mx * rides);
48.     }
49.     cout << mn;
50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top