結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-09 01:10:56 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 59 ms / 1,000 ms |
| コード長 | 632 bytes |
| コンパイル時間 | 485 ms |
| コンパイル使用メモリ | 82,024 KB |
| 実行使用メモリ | 71,528 KB |
| 最終ジャッジ日時 | 2024-09-09 01:11:02 |
| 合計ジャッジ時間 | 5,379 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
import sys
sys.setrecursionlimit(int(1e6))
input = lambda: sys.stdin.readline().rstrip("\r\n")
MOD = 998244353
INF = int(4e18)
if __name__ == "__main__":
_ = int(input())
s = input()
nums = [int(v) for v in s]
res = nums.count(3) + nums.count(5) + nums.count(7) # 3, 5, 7
c1 = 0
c9 = 0
for s in nums:
if s == 1:
c1 += 1
elif s == 9: # 19
if c1:
res += 1
c1 -= 1
else:
c9 += 1
while c9 >= 2 and c1: # 991
res += 1
c9 -= 2
c1 -= 1
res += c1 // 2 # 11
print(res)