結果
問題 | No.1594 Three Classes |
ユーザー |
|
提出日時 | 2021-07-09 22:13:09 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,164 bytes |
コンパイル時間 | 196 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 17,692 KB |
最終ジャッジ日時 | 2024-07-01 16:45:08 |
合計ジャッジ時間 | 4,998 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 14 WA * 3 TLE * 1 |
ソースコード
from itertools import combinations N = int(input()) E = [int(i) for i in input().split()] se = set(E) SE = sum(E) if SE % 3 != 0: print("No") exit() used = set() def recur(cur, group): if group == 3: print("Yes") exit() for e in se - set(used): if e + cur < SE // 3: used.add(e) recur(cur + e, group) used.remove(e) elif e + cur == SE // 3: used.add(e) recur(0, group+1) used.remove(e) elif e + cur > SE // 3: return recur(0, 0) print("No") # from itertools import permutations # # N = int(input()) # E = [int(i) for i in input().split()] # se = sum(E) # if se % 3 != 0: # print("No") # exit() # # def possible(arr): # cur = 0 # count = 0 # for i in arr: # if i + cur < se // 3: # cur += i # elif i + cur == se // 3: # cur = 0 # count += 1 # elif i + cur > se//3: # return False # return count == 3 and cur == 0 # # for per in permutations(E, N): # if possible(per): # print("Yes") # exit() # print("No")