結果
問題 |
No.332 数列をプレゼントに
|
ユーザー |
![]() |
提出日時 | 2020-03-24 14:47:19 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 738 bytes |
コンパイル時間 | 338 ms |
コンパイル使用メモリ | 82,448 KB |
実行使用メモリ | 67,456 KB |
最終ジャッジ日時 | 2024-12-31 15:01:40 |
合計ジャッジ時間 | 10,569 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 5 |
other | RE * 42 |
ソースコード
#!/usr/bin/env python3 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N, X, *A = map(int, read().split()) B = sorted(A) def dfs(B, S): if sum(B) < S: return False if sum(B) == S: return B.copy() x = B.pop() if x < S: res = dfs(B, S - x) if res: return res + [x] res = dfs(B, S) B.append(x) return res C = dfs(B, X) if C: C.sort() i = 0 res = set(range(N)) answer = ['x'] * N for c in C: for i in res: if A[i] == c: break res.remove(i) answer[i] = 'o' print(''.join(answer)) else: print('No')