結果

問題 No.145 yukiover
ユーザー yaoshimaxyaoshimax
提出日時 2015-05-01 01:21:42
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 1,364 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 6,748 KB
実行使用メモリ 6,204 KB
最終ジャッジ日時 2023-09-19 04:47:12
合計ジャッジ時間 2,003 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,936 KB
testcase_01 AC 11 ms
6,088 KB
testcase_02 AC 11 ms
5,932 KB
testcase_03 AC 12 ms
5,852 KB
testcase_04 AC 11 ms
5,836 KB
testcase_05 AC 11 ms
5,856 KB
testcase_06 AC 12 ms
6,092 KB
testcase_07 AC 11 ms
5,888 KB
testcase_08 WA -
testcase_09 AC 12 ms
6,016 KB
testcase_10 AC 12 ms
5,880 KB
testcase_11 AC 33 ms
5,972 KB
testcase_12 AC 34 ms
6,028 KB
testcase_13 AC 33 ms
5,936 KB
testcase_14 AC 33 ms
6,160 KB
testcase_15 WA -
testcase_16 AC 33 ms
5,952 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 33 ms
6,012 KB
testcase_20 AC 33 ms
6,156 KB
testcase_21 WA -
testcase_22 AC 33 ms
5,972 KB
testcase_23 AC 33 ms
6,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(raw_input())
S=raw_input()
cnt=[0 for i in range(30)]
for s in S:
    cnt[ord(s)-ord('a')]+=1
ans=0
m=N
for i in range(ord('z'),ord('a')-1,-1):
    if i > ord('y'):
        ans+=cnt[i-ord('a')]
    elif i == ord('y'):
        m=min(m,cnt[i-ord('a')])
    elif i > ord('u'):
        ans+=min(m,cnt[i-ord('a')])
        m-=min(m,cnt[i-ord('a')])
    elif i == ord('u'):
        if cnt[i-ord('a')]>m:
            ans+=min(m,cnt[i-ord('a')]-m)
            m-=min(m,cnt[i-ord('a')]-m)
        else:
            ans+=(m-cnt[i-ord('a')]+1)/2
            m-=(m-cnt[i-ord('a')]+1)/2
    elif i > ord('k'):
        ans+=min(m,cnt[i-ord('a')])
        m-=min(m,cnt[i-ord('a')])
    elif i == ord('k'):
        if cnt[i-ord('a')]>m:
            ans+=min(m,cnt[i-ord('a')]-m)
            m-=min(m,cnt[i-ord('a')]-m)
        else:
            ans+=(m-cnt[i-ord('a')]+1)/2
            m-=(m-cnt[i-ord('a')]+1)/2
    elif i > ord('i'):
        ans+=min(m,cnt[i-ord('a')])
        m-=min(m,cnt[i-ord('a')])
    elif i== ord('i'):
        if cnt[i-ord('a')]>m:
            ans+=min(m,cnt[i-ord('a')]-m)
            m-=min(m,cnt[i-ord('a')]-m)
        else:
            ans+=(m-cnt[i-ord('a')]+1)/2
            m-=(m-cnt[i-ord('a')]+1)/2
    else:
        ans+=min(m,cnt[i-ord('a')])
        m-=min(m,cnt[i-ord('a')])
    #print chr(i),cnt[i-ord('a')],"=>",ans,m
print ans+m/2
0