結果
| 問題 | No.332 数列をプレゼントに |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-24 14:46:53 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 738 bytes |
| 記録 | |
| コンパイル時間 | 246 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 88,532 KB |
| 最終ジャッジ日時 | 2024-12-31 15:01:24 |
| 合計ジャッジ時間 | 35,890 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 39 TLE * 3 |
ソースコード
#!/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')
maspy