結果
問題 |
No.910 素数部分列
|
ユーザー |
|
提出日時 | 2020-04-12 17:09:06 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 666 bytes |
コンパイル時間 | 416 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 12,788 KB |
最終ジャッジ日時 | 2024-09-22 02:43:12 |
合計ジャッジ時間 | 4,557 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 WA * 7 |
ソースコード
MOD = 10 ** 9 + 7 INF = 10 ** 10 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) def main(): n = int(input()) s = input() stack = [-1] cnt9 = 0 ans = 0 for i in range(n): if s[i] in '357': ans += 1 elif s[i] == '9': if stack[-1] == '1': ans += 1 stack.pop() else: cnt9 += 1 else: stack.append(s[i]) cnt1 = stack.count('1') while cnt1 > 0 and cnt9 > 0: cnt1 -= 1 cnt9 -= 2 ans += 1 ans += cnt1//2 print(ans) if __name__ =='__main__': main()