結果
問題 | No.1231 Make a Multiple of Ten |
ユーザー | けむけむ |
提出日時 | 2021-08-29 21:40:33 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 122 ms / 2,000 ms |
コード長 | 634 bytes |
コンパイル時間 | 158 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 32,868 KB |
最終ジャッジ日時 | 2024-05-02 00:16:12 |
合計ジャッジ時間 | 2,525 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
10,752 KB |
testcase_01 | AC | 26 ms
10,752 KB |
testcase_02 | AC | 27 ms
10,752 KB |
testcase_03 | AC | 26 ms
10,624 KB |
testcase_04 | AC | 67 ms
20,672 KB |
testcase_05 | AC | 64 ms
19,360 KB |
testcase_06 | AC | 40 ms
14,660 KB |
testcase_07 | AC | 70 ms
21,084 KB |
testcase_08 | AC | 52 ms
15,712 KB |
testcase_09 | AC | 40 ms
13,372 KB |
testcase_10 | AC | 67 ms
19,944 KB |
testcase_11 | AC | 76 ms
21,684 KB |
testcase_12 | AC | 87 ms
31,884 KB |
testcase_13 | AC | 120 ms
32,868 KB |
testcase_14 | AC | 27 ms
10,624 KB |
testcase_15 | AC | 122 ms
32,544 KB |
ソースコード
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()