Cod sursa(job #2305732)

Utilizator Andrei-27Arhire Andrei Andrei-27 Data 20 decembrie 2018 22:27:13
Problema PalM Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <fstream>

using namespace std ;


ifstream f ("palm.in") ;
ofstream g ("palm.out") ;

int main ()
{
  
  char c , a ; f >> a ;
  int nrneg = 1 , nrcres = 1 , maxim  = 1 ;
  while ( f >> c )
  {
      if ( c > a )  nrcres ++ , nrneg = 1 ;
      if ( c < a )  nrneg = max ( nrneg , nrcres ) + 1 , nrcres = 1 ;
      if ( c == a)  nrcres ++ , nrneg ++ ;
      if ( nrneg > maxim )  maxim = nrneg ;
      if ( nrcres > maxim ) maxim = nrcres ;
      a = c ;
  }
    
    
        g << maxim ;
        
        
        
    
    
    
}