結果

問題 No.145 yukiover
ユーザー yaoshimaxyaoshimax
提出日時 2015-05-01 01:18:28
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 1,331 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 6,548 KB
実行使用メモリ 6,208 KB
最終ジャッジ日時 2023-09-19 04:47:06
合計ジャッジ時間 2,209 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,856 KB
testcase_01 AC 11 ms
5,928 KB
testcase_02 AC 12 ms
5,848 KB
testcase_03 AC 12 ms
5,932 KB
testcase_04 AC 11 ms
5,852 KB
testcase_05 AC 11 ms
5,932 KB
testcase_06 AC 11 ms
5,956 KB
testcase_07 AC 12 ms
5,856 KB
testcase_08 AC 12 ms
5,852 KB
testcase_09 AC 12 ms
5,984 KB
testcase_10 WA -
testcase_11 AC 33 ms
6,060 KB
testcase_12 AC 34 ms
6,060 KB
testcase_13 AC 33 ms
6,032 KB
testcase_14 AC 33 ms
5,984 KB
testcase_15 AC 33 ms
5,948 KB
testcase_16 AC 33 ms
5,948 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 34 ms
6,032 KB
testcase_20 AC 33 ms
5,940 KB
testcase_21 AC 33 ms
6,052 KB
testcase_22 AC 33 ms
6,120 KB
testcase_23 AC 33 ms
5,984 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')])/2
            m=cnt[i-ord('a')]
    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')])/2
            m=cnt[i-ord('a')]
    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')])/2
            m=cnt[i-ord('a')]
    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