PYRAMID2 - Duyệt binh
Tác giả: khuc_tuan
Ngôn ngữ: Java
import java.io.*;
public class Main{
public static void main(String[] Args) throws Exception {
BufferedReader kb=new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(kb.readLine());
int tgc=0,ss1=0,res=0;
char c, ct=(char)0;
boolean bd2=false,bd=false;
String s = kb.readLine();
for(int i=0;i<n;++i) {
c=s.charAt(i);
if(!bd) {
if(c=='<') continue;
else bd=true;
}
if(c=='>') {
++ss1;
if( bd2 && tgc>0 ) --tgc;
}
else {
if(!bd2) bd2=true;
res=Math.max(res,ss1+Math.max(tgc,0));
++tgc;
}
ct=c;
}
System.out.println(res);
}
}