結果
問題 |
No.332 数列をプレゼントに
|
ユーザー |
![]() |
提出日時 | 2025-06-12 14:26:28 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,041 bytes |
コンパイル時間 | 353 ms |
コンパイル使用メモリ | 82,688 KB |
実行使用メモリ | 277,152 KB |
最終ジャッジ日時 | 2025-06-12 14:26:39 |
合計ジャッジ時間 | 9,714 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 7 WA * 4 TLE * 1 MLE * 1 -- * 29 |
ソースコード
n, X = map(int, input().split()) A = list(map(int, input().split())) sum_total = sum(A) if sum_total < X: print("No") elif sum_total == X: print('o' * n) else: found = False for i in range(n): if A[i] == X: s = ['x'] * n s[i] = 'o' print(''.join(s)) found = True break if found: exit() mask = 1 for a in A: if a > X: continue mask |= mask << a mask &= (1 << (X + 1)) - 1 if not (mask & (1 << X)): print("No") else: selected = [False] * n current_sum = X for i in reversed(range(n)): a = A[i] if a > current_sum: continue if (mask >> (current_sum - a)) & 1: selected[i] = True current_sum -= a if current_sum == 0: break s = [] for i in range(n): s.append('o' if selected[i] else 'x') print(''.join(s))