結果
問題 | No.1231 Make a Multiple of Ten |
ユーザー |
|
提出日時 | 2021-08-29 21:40:33 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 140 ms / 2,000 ms |
コード長 | 634 bytes |
コンパイル時間 | 99 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 32,872 KB |
最終ジャッジ日時 | 2024-11-22 08:56:05 |
合計ジャッジ時間 | 2,733 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
from itertools import combinations def Ten(N, A): sumA = sum(A) if sumA % 10 == 0: return N tens = [] for i in range(1, N // 2 + 1): combs = list(combinations(A, i)) for j in range(len(combs)): sumj1 = sum(combs[j]) sumj2 = sumA - sumj1 if sumj1 % 10 == 0: tens.append(i) if sumj2 % 10 == 0: return N - i if len(tens) > 0: return max(tens) else: return 0 def main(): N = int(input()) A = list(map(int, input().split())) print(Ten(N, A)) if __name__ == '__main__': main()