GastonFontenla

Untitled

Oct 26th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. void maraton(vector <int> numeroCorredor, vector <int> categoriaCorredor,
  7.              vector <int> &ganadores)
  8. {
  9.     ganadores.resize(10, 0);
  10.  
  11.     for(int i=0; i<numeroCorredor.size(); i++)
  12.     {
  13.         int num = numeroCorredor[i];
  14.         int cat = categoriaCorredor[i];
  15.  
  16.         if(ganadores[cat-1] == 0)
  17.         {
  18.             ganadores[cat-1] = num;
  19.         }
  20.     }
  21. }
  22.  
  23. int main()
  24. {
  25.     int n;
  26.     cin >> n;
  27.     vector <int> numeroCorredor(n);
  28.     vector <int> categoriaCorredor(n);
  29.  
  30.     for(int i=0; i<n; i++)
  31.     {
  32.         cin >> numeroCorredor[i] >> categoriaCorredor[i];
  33.     }
  34.  
  35.     vector <int> ganadores;
  36.  
  37.     maraton(numeroCorredor, categoriaCorredor, ganadores);
  38.  
  39.     for(int i=0; i<10; i++)
  40.     {
  41.         cout << i+1 << " " << ganadores[i] << endl;
  42.     }
  43.  
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment