結果
問題 | No.10 +か×か |
ユーザー |
![]() |
提出日時 | 2025-03-26 15:45:56 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 889 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 82,244 KB |
実行使用メモリ | 76,688 KB |
最終ジャッジ日時 | 2025-03-26 15:46:17 |
合計ジャッジ時間 | 7,248 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 TLE * 1 -- * 7 |
ソースコード
def solve():N = int(input())Total = int(input())A = list(map(int, input().split()))def backtrack(index, current_val, ops):if index == N - 1:return ops if current_val == Total else Nonenext_num = A[index + 1]# Try '+' first to maintain lex ordernew_plus = current_val + next_numif new_plus <= Total:result = backtrack(index + 1, new_plus, ops + ['+'])if result is not None:return result# Try '*' if '+' doesn't worknew_mul = current_val * next_numif new_mul <= Total:result = backtrack(index + 1, new_mul, ops + ['*'])if result is not None:return resultreturn Noneresult_ops = backtrack(0, A[0], [])print(''.join(result_ops))solve()