結果
問題 | No.10 +か×か |
ユーザー | vwxyz |
提出日時 | 2021-06-28 17:06:15 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 251 ms / 5,000 ms |
コード長 | 1,194 bytes |
コンパイル時間 | 249 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 128,384 KB |
最終ジャッジ日時 | 2024-05-08 12:04:41 |
合計ジャッジ時間 | 3,276 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 156 ms
89,472 KB |
testcase_01 | AC | 152 ms
89,856 KB |
testcase_02 | AC | 154 ms
89,728 KB |
testcase_03 | AC | 247 ms
128,256 KB |
testcase_04 | AC | 219 ms
115,456 KB |
testcase_05 | AC | 155 ms
89,472 KB |
testcase_06 | AC | 251 ms
128,384 KB |
testcase_07 | AC | 233 ms
115,200 KB |
testcase_08 | AC | 189 ms
96,640 KB |
testcase_09 | AC | 199 ms
103,040 KB |
testcase_10 | AC | 162 ms
89,728 KB |
testcase_11 | AC | 161 ms
89,856 KB |
ソースコード
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='')