結果

問題 No.911 ラッキーソート
ユーザー hrbt__
提出日時 2019-11-26 21:02:03
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 377 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-11-07 00:56:03
合計ジャッジ時間 3,473 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
s = ''.join(s.split('3'))
s = ''.join(s.split('5'))
s = ''.join(s.split('7'))
ans = n - len(s)
c1 = 0
c9 = 0
for c in s:
    if c == '1':
        c1 += 1
    else:
        if c1 > 0:
            ans += 1
            c1 -= 1
        else:
            c9 += 1
while c1 >= 1 and c9 >= 2:
    ans += 1
    c1 -= 1
    c9 -= 2
ans += c1 // 2
print(ans)
0