結果
問題 | No.10 +か×か |
ユーザー |
![]() |
提出日時 | 2020-03-24 14:05:00 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 46 ms / 5,000 ms |
コード長 | 623 bytes |
コンパイル時間 | 102 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 13,568 KB |
最終ジャッジ日時 | 2024-12-14 15:43:44 |
合計ジャッジ時間 | 1,108 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, T, *A = map(int, read().split()) dp = [set() for _ in range(N + 1)] dp[N].add(T) for n in range(N, 0, -1): x = A[n - 1] for y in dp[n]: if 0 <= y - x: dp[n - 1].add(y - x) if y % x == 0: dp[n - 1].add(y // x) assert 0 in dp[0] answer = [] x = 0 for n in range(1, N + 1): y = A[n - 1] if x + y in dp[n]: answer.append('+') x += y else: answer.append('*') x *= y print(''.join(answer[1:]))