結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
5,996 KB
testcase_01 AC 13 ms
5,876 KB
testcase_02 AC 12 ms
6,012 KB
testcase_03 AC 11 ms
5,852 KB
testcase_04 AC 12 ms
5,848 KB
testcase_05 AC 12 ms
5,836 KB
testcase_06 AC 11 ms
5,888 KB
testcase_07 AC 12 ms
6,040 KB
testcase_08 AC 11 ms
5,864 KB
testcase_09 AC 12 ms
6,020 KB
testcase_10 AC 11 ms
5,880 KB
testcase_11 AC 33 ms
5,932 KB
testcase_12 AC 33 ms
6,060 KB
testcase_13 AC 33 ms
6,064 KB
testcase_14 AC 33 ms
5,936 KB
testcase_15 AC 33 ms
6,204 KB
testcase_16 AC 33 ms
6,168 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 33 ms
6,032 KB
testcase_20 AC 33 ms
5,976 KB
testcase_21 AC 34 ms
6,200 KB
testcase_22 AC 34 ms
5,948 KB
testcase_23 AC 34 ms
5,948 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)*2
            if(m-cnt[i-ord('a')])%2>0:
                m-=1
                ans+=1
    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)*2
            if(m-cnt[i-ord('a')])%2>0:
                m-=1
                ans+=1
    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)*2
            if(m-cnt[i-ord('a')])%2>0:
                m-=1
                ans+=1
    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