irapilguy

Светлячки

Nov 12th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. using namespace std;
  4. #define N 200000
  5. #define H 500000
  6. int masPar[N] = { 0 };
  7. int masNePar[N] = { 0 };
  8. int res[H] = { 0 };
  9. int nePar(int x, int n) {
  10.     int count = 0;
  11.     for (int i = 1; i <= n; i++) if (masNePar[i] >= x) count++;
  12.     return count;
  13. }
  14. int par(int x,int n){
  15.     int count = 0;
  16.     for (int i = 1; i <= n; i++) if (masPar[i] >= x) count++;
  17.     return 0;
  18. }
  19. void way( int h) {
  20.     int min = res[1];
  21.     int  count = 0;
  22.     for (int i = 1; i <= h; i++) {
  23.         if (min > res[i])   min = res[i];
  24.     }
  25.     for (int i = 1; i <= h; i++) {
  26.         if (res[i] == min) count++;
  27.     }
  28.     cout << min << " " << count;
  29. }
  30. int main() {
  31.     ios_base::sync_with_stdio(false);
  32.     cin.tie(NULL);
  33.     int n, h;
  34.     cin >> n >> h;
  35.     for (int i = 1; i <= n; i++) {
  36.         int x;
  37.         cin >> x;
  38.         if (i % 2 == 0) {
  39.             masPar[i] = x;
  40.         }
  41.         else masNePar[i] = x;
  42.     }
  43.     int i = 1;
  44.     int j = h;
  45.     while (i <= h && j >= 1) {
  46.         int res1 = nePar(i, n);
  47.         cout << "res1" <<"  -  " << res1 << "\n";
  48.         int res2 = par(j, n);
  49.         cout << "res2" << "  -  " << res2 << "\n";
  50.         res[i] = res1 + res2;
  51.         i++;
  52.         j--;
  53.     }
  54.     way(h);
  55.     return 0;
  56. }
Add Comment
Please, Sign In to add comment