結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2021-06-28 17:06:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 240 ms / 5,000 ms |
| コード長 | 1,194 bytes |
| コンパイル時間 | 180 ms |
| コンパイル使用メモリ | 82,460 KB |
| 実行使用メモリ | 128,868 KB |
| 最終ジャッジ日時 | 2024-12-14 15:48:19 |
| 合計ジャッジ時間 | 3,061 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
ソースコード
import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
from collections import Counter, deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
heap.append(item)
heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
if heap and item < heap[0]:
item, heap[0] = heap[0], item
heapq._siftup_max(heap, 0)
return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
N=int(readline())
total=int(readline())
A=list(map(int,readline().split()))
dp=[[False]*(total+1) for i in range(N)]
dp[N-1][total]=True
for i in range(N-2,-1,-1):
a=A[i+1]
for t in range(total+1):
if dp[i+1][t]:
if 0<=t-a:
dp[i][t-a]=True
if t%a==0:
dp[i][t//a]=True
ans_lst=[]
s=A[0]
for i in range(1,N):
a=A[i]
if s+a<=total and dp[i][s+a]:
s+=a
ans_lst.append('+')
else:
s*=a
ans_lst.append('*')
print(*ans_lst,sep='')
vwxyz