Codeforces Round #230 (Div. 2)
はい。
http://codeforces.com/contest/393
A. Nineteen
ざっくりと大意
・Aliceは"nineteen"という文字列が大好きで与えられる文字列sを並び替えて沢山の"nineteen"をつくりたい??
方針のようなもの
・サンプルを見ると”nineteenineteen"で末尾と先頭でnは重複して利用できるようなのでそれで。
n=raw_input() ans=chk=0 w=['n','i','e','t'] s=[0]*4 for i in n: if i=='n': s[0]+=1 elif i=='i': s[1]+=1 elif i=='e': s[2]+=1 elif i=='t': s[3]+=1 while 1: chk=ans if ans==0: if s[0]>=3 and s[1]>=1 and s[2]>=3 and s[3]>=1: s[0]-=3 s[1]-=1 s[2]-=3 s[3]-=1 ans+=1 else: if s[0]>=2 and s[1]>=1 and s[2]>=3 and s[3]>=1: s[0]-=2 s[1]-=1 s[2]-=3 s[3]-=1 ans+=1 if chk==ans: break print ans
ループを回さなくても多分割り算でもイケルと思う。