rendered paste body/*ID: indy901PROG: beadsLANG: C*/#include <stdio.h>#include <stdlib.h>int N;int i;int j;int maxBeads;int gotColor;char color;char* beads;FILE* fp;void countBeads( int i ) { if ( beads[ i ] == 'w' ) maxBeads++; else if ( gotColor == 1 ) { if ( color != beads[ i ] ) break; else maxBeads++; } else { color = beads[ i ]; gotColor = 1; maxBeads++; }}int main() { fp = fopen( "beads.in" , "r" ); fscanf( fp , "%d" , &N ); beads = ( char* )malloc( sizeof( char ) * N ); fscanf( fp , "%s" , beads ); maxBeads = 0; gotColor = 0; for ( i = 0; i < N; i++ ) countBeads( i ); for ( j = N; j > i; j-- ) countBeads( j ); fclose( fp ); fp = fopen( "beads.out" , "w" ); fprintf( fp , "%d\n" , maxBeads ); fclose( fp ); free( beads ); return 0;}