結果

問題 No.145 yukiover
ユーザー yaoshimaxyaoshimax
提出日時 2015-05-01 00:43:53
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 888 bytes
コンパイル時間 865 ms
コンパイル使用メモリ 6,520 KB
実行使用メモリ 6,220 KB
最終ジャッジ日時 2023-09-19 04:46:44
合計ジャッジ時間 2,928 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,956 KB
testcase_01 AC 12 ms
6,000 KB
testcase_02 AC 12 ms
5,960 KB
testcase_03 AC 12 ms
6,044 KB
testcase_04 AC 11 ms
5,968 KB
testcase_05 WA -
testcase_06 AC 12 ms
5,848 KB
testcase_07 AC 12 ms
5,940 KB
testcase_08 WA -
testcase_09 AC 12 ms
5,960 KB
testcase_10 WA -
testcase_11 AC 33 ms
5,984 KB
testcase_12 WA -
testcase_13 AC 33 ms
5,936 KB
testcase_14 AC 33 ms
5,936 KB
testcase_15 WA -
testcase_16 AC 34 ms
6,212 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 33 ms
6,140 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'):
        m=min(m,cnt[i-ord('a')])
        if cnt[i-ord('a')]>m:
            ans+=min(m,cnt[i-ord('a')]-m)
            m-=min(m,cnt[i-ord('a')]-m)
    elif i > ord('k'):
        ans+=min(m,cnt[i-ord('a')])
        m-=min(m,cnt[i-ord('a')])
    elif i == ord('k'):
        m=min(m,cnt[i-ord('a')])
        if cnt[i-ord('a')]>m:
            ans+=min(m,cnt[i-ord('a')]-m)
            m-=min(m,cnt[i-ord('a')]-m)
    elif i > ord('i'):
        ans+=min(m,cnt[i-ord('a')])
        m-=min(m,cnt[i-ord('a')])
print ans+m/2
0