egogoboy

Чемпионат по стрельбе

Jul 6th, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8.     std::ifstream fin("input.txt");
  9.     std::ofstream fout("output.txt");
  10.  
  11.     int n;
  12.     fin >> n;
  13.     vector<int> players;
  14.     int x, max = 0;
  15.  
  16.     for (int i = 0; i < n; i++) {
  17.  
  18.         fin >> x;
  19.         players.push_back(x);
  20.         if (players[max] < players[i]) {
  21.             max = i;
  22.         }
  23.  
  24.     }
  25.    
  26.     int dad = -1, dad_id = -1;
  27.    
  28.     for (int i = max + 1; i < players.size() - 1; i++) {
  29.         if (players[i] > players[i + 1] && players[i] > dad && players[i] % 10 == 5) {
  30.             dad_id = i;
  31.             dad = players[i];
  32.         }
  33.     }
  34.  
  35.     int answ = 0;
  36.  
  37.     if (dad_id != -1) {
  38.         for (int i = 0; i < players.size(); i++) {
  39.             if (players[i] > players[dad_id]) {
  40.                 answ++;
  41.             }
  42.         }
  43.         answ++;
  44.     }
  45.    
  46.     fout << answ << endl;
  47.     return 0;
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment