Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define N 200000
- #define H 500000
- int hight[N] = { 0 };
- int res[H] = { 0 };
- void way( int h) {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int min = res[1];
- int count = 0;
- for (int i = 1; i <= h; i++) {
- if (res[i] == min) count++;
- if (min > res[i]) {
- count = 1;
- min = res[i];
- }
- }
- cout << min << " " << count;
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int n, h;
- cin >> n >> h;
- for (int i = 1; i <= n; i++) {
- int x;
- cin >> x;
- if (i % 2 == 0) {
- hight[h - x + 1]++;
- }
- else {
- hight[1]++;
- hight[x + 1]--;
- }
- }
- res[1] = hight[1];
- for (int i = 2; i <= h; i++) res[i] = res[i - 1] + hight[i];
- way(h);
- return 0;
- }
Add Comment
Please, Sign In to add comment