Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. const int I_MAX_CHANSONS = 100000;
  7. const int INFINI = 1000*1000*1000;
  8.  
  9. int degreUtilisation[I_MAX_CHANSONS+1];
  10. int nbUtilisesMax = -INFINI;
  11.  
  12. int main()
  13. {
  14.     int nbChansons;
  15.     scanf("%d", &nbChansons);
  16.  
  17.     int iSeq = 1, nbUtilises = 0;
  18.  
  19.     for(int iChanson = 1 ; iChanson <= nbChansons ; iChanson++)
  20.     {
  21.         int curChanson;
  22.         scanf("%d", &curChanson);
  23.  
  24.         if(curChanson == 0)
  25.         {
  26.             nbUtilises = 0;
  27.             iSeq++;
  28.         }
  29.         else if(degreUtilisation[curChanson] != iSeq)
  30.         {
  31.             nbUtilises++;
  32.             degreUtilisation[curChanson] = iSeq;
  33.         }
  34.  
  35.         if(nbUtilises > nbUtilisesMax)
  36.                 nbUtilisesMax = nbUtilises;
  37.     }
  38.  
  39.     printf("%d", nbUtilisesMax);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement