Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. ifstream fin("platou1.in");
  5. ofstream fout("platou1.out");
  6. int main()
  7. {
  8. int x,y,lmax=0,lung=1,minn=999999999;
  9. fin>>x;
  10. while(fin>>y){
  11. if(x==y){
  12. lung++;
  13. }
  14. else{
  15. if(lung>lmax){
  16. lmax=lung;
  17. minn=x;
  18. }
  19. else
  20. {
  21. if(lmax==lung){
  22. if(x<minn){
  23. minn=x;
  24. }
  25. }
  26.  
  27. }
  28. lung=1; ///sirul este format doar din y
  29. }
  30. x=y;
  31. }
  32. if(lung>lmax){
  33. minn=y;
  34. lmax=lung;
  35. }
  36. else{
  37. if(lung==lmax){
  38. if(y<minn){
  39. minn=y;
  40. }
  41. }
  42. }
  43. fout<<lmax<<" "<<minn;
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement