Pagini recente » Infoarena Monthly 2014 - Runda 2 | Cod sursa (job #2568327) | Cod sursa (job #829825) | Cod sursa (job #397926) | Cod sursa (job #2305732)
#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 ;
}