Advertisement
Guest User

platou1

a guest
Dec 16th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream in ("platou1.in");
  7. ofstream out ("platou1.out");
  8.  
  9. int main () {
  10.   int a, b, l, lmax, nmax;
  11.   nmax = 100000;
  12.   lmax = 0;
  13.   l = 1;
  14.   in >> a;
  15.   while (in >> b){
  16.     if (a == b) {
  17.       l ++;
  18.     }
  19.     else {
  20.       l = 1;
  21.     }
  22.     if (l > lmax || (l == lmax && a < nmax)) {
  23.       lmax = l;
  24.       nmax = a;
  25.     }
  26.     a = b;
  27.   }
  28.   out << lmax << " " << nmax;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement