Advertisement
Josif_tepe

Untitled

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