結果
問題 | No.10 +か×か |
ユーザー | ayaoni |
提出日時 | 2020-12-04 09:48:43 |
言語 | PyPy3 (7.3.13) |
結果 |
WA
|
実行時間 | - |
コード長 | 896 bytes |
コンパイル時間 | 399 ms |
コンパイル使用メモリ | 87,072 KB |
実行使用メモリ | 115,608 KB |
最終ジャッジ日時 | 2023-10-12 21:58:07 |
合計ジャッジ時間 | 3,038 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
71,216 KB |
testcase_01 | AC | 71 ms
71,220 KB |
testcase_02 | AC | 71 ms
71,216 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 74 ms
71,264 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 136 ms
89,668 KB |
testcase_10 | AC | 82 ms
76,096 KB |
testcase_11 | AC | 81 ms
76,008 KB |
ソースコード
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) N = I() total = I() A = LI() dp = [[0]*(total+1) for _ in range(N)] dp[0][A[0]] = 1 for i in range(1,N): a = A[i] for j in range(1,total+1): if j >= a: dp[i][j] |= dp[i-1][j-a] if j % a == 0: dp[i][j] |= dp[i-1][j//a] ans = '' x = total for i in range(N-1,0,-1): a = A[i] if dp[i-1][x-a]: ans += '+' x -= a else: ans += '*' x //= a print(ans[::-1])