Lucian_Adrian

Untitled

Jan 25th, 2022
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. using namespace std;
  4. ifstream cin("cartonase.in");
  5. ofstream cout("cartonase.out");
  6. int n , x , y , cer , st , dr , cnt , p , lmax , cate;
  7. int main()
  8. {
  9. cin >> cer >> n;
  10. for(int i = 1 ; i <= n ; i++)
  11. {
  12. cin >> x >> y;
  13. if(x == dr)
  14. {
  15. cate++;
  16. cnt++;
  17. }
  18. else
  19. {
  20. if(cnt > lmax) lmax = cnt , p = 0;
  21. else if(cnt == lmax) p++;
  22. cnt = 0;
  23. }
  24. st = x , dr = y;
  25. }
  26. if(cnt > 0)
  27. {
  28. if(cnt > lmax) lmax = cnt;
  29. else if(cnt == lmax) p++;
  30. }
  31. if(cer == 1)cout << cate;
  32. else if(cer == 2) cout << lmax + 1;
  33. else cout << p + 1;
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment