Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef int64_t i64;
- using d6 = long double;
- int main()
- {
- i64 n, h;
- cin >> n >> h;
- map<i64, i64> ua, dw;
- for (i64 i = 0; i < n; i++)
- {
- i64 tmp;
- cin >> tmp;
- if (i % 2 == 0)
- {
- ua[tmp] += 1;
- }
- else
- {
- dw[tmp] += 1;
- }
- }
- i64 res = n;
- i64 resc = 0;
- i64 tu = n / 2;
- i64 tw = 0;
- for (i64 i = 1; i <= h; i++)
- {
- if (ua.count(i) > 0)
- {
- tu -= ua[i];
- }
- if (dw.count(h - i) > 0)
- {
- tw += dw[h - i];
- }
- if (res > tu + tw)
- {
- res = tu + tw;
- resc = 1;
- }
- else
- {
- if (res == tu + tw)
- {
- resc += 1;
- }
- }
- }
- cout << res << " " << resc << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment