Advertisement
Josif_tepe

Untitled

Feb 12th, 2024
1,233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.    
  9.     int rodendni[13][32];
  10.     for(int i = 1; i <= 12; i++) {
  11.         for(int j = 1; j <= 31; j++) {
  12.             rodendni[i][j] = 0;
  13.         }
  14.     }
  15.     for(int i = 0; i < n; i++) {
  16.         int x, y;
  17.         cin >> x >> y;
  18.         rodendni[y][x] = 1;
  19.     }
  20.     int max_brojac = 0;
  21.     vector<int> meseci;
  22.     for(int mesec = 1; mesec <= 12; mesec++) {
  23.         int brojac = 0;
  24.         for(int den = 1; den <= 31; den++) {
  25.             if(rodendni[mesec][den] == 1) {
  26.                 brojac++;
  27.             }
  28.         }
  29.         if(brojac > max_brojac) {
  30.             max_brojac = brojac;
  31.             meseci.clear();
  32.             meseci.push_back(mesec);
  33.         }
  34.         else if(brojac == max_brojac) {
  35.             meseci.push_back(mesec);
  36.         }
  37.     }
  38.     for(int i = 0; i < meseci.size(); i++) {
  39.         cout << meseci[i] << endl;
  40.     }
  41.  
  42.    
  43.     return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement