Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- using namespace std;
- #define N 200000
- #define H 500000
- int masPar[N] = { 0 };
- int masNePar[N] = { 0 };
- int res[H] = { 0 };
- int nePar(int x, int n) {
- int count = 0;
- for (int i = 1; i <= n; i++) if (masNePar[i] >= x) count++;
- return count;
- }
- int par(int x,int n){
- int count = 0;
- for (int i = 1; i <= n; i++) if (masPar[i] >= x) count++;
- return 0;
- }
- void way( int h) {
- int min = res[1];
- int count = 0;
- for (int i = 1; i <= h; i++) {
- if (min > res[i]) min = res[i];
- }
- for (int i = 1; i <= h; i++) {
- if (res[i] == min) count++;
- }
- 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) {
- masPar[i] = x;
- }
- else masNePar[i] = x;
- }
- int i = 1;
- int j = h;
- while (i <= h && j >= 1) {
- int res1 = nePar(i, n);
- cout << "res1" <<" - " << res1 << "\n";
- int res2 = par(j, n);
- cout << "res2" << " - " << res2 << "\n";
- res[i] = res1 + res2;
- i++;
- j--;
- }
- way(h);
- return 0;
- }
Add Comment
Please, Sign In to add comment