結果
問題 | No.1929 Exponential Sequence |
ユーザー | lilictaka |
提出日時 | 2022-05-21 12:06:19 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,819 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 81,840 KB |
実行使用メモリ | 135,304 KB |
最終ジャッジ日時 | 2023-10-20 15:53:17 |
合計ジャッジ時間 | 14,653 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
53,580 KB |
testcase_01 | AC | 46 ms
59,724 KB |
testcase_02 | AC | 90 ms
75,788 KB |
testcase_03 | AC | 622 ms
130,568 KB |
testcase_04 | AC | 1,093 ms
75,932 KB |
testcase_05 | AC | 42 ms
57,676 KB |
testcase_06 | AC | 41 ms
53,580 KB |
testcase_07 | AC | 133 ms
75,928 KB |
testcase_08 | AC | 38 ms
53,516 KB |
testcase_09 | AC | 94 ms
75,668 KB |
testcase_10 | AC | 43 ms
57,676 KB |
testcase_11 | AC | 137 ms
75,640 KB |
testcase_12 | TLE | - |
testcase_13 | AC | 1,234 ms
75,908 KB |
testcase_14 | TLE | - |
testcase_15 | AC | 1,169 ms
76,260 KB |
testcase_16 | AC | 130 ms
75,964 KB |
testcase_17 | AC | 43 ms
57,676 KB |
testcase_18 | AC | 38 ms
53,580 KB |
testcase_19 | AC | 38 ms
53,516 KB |
testcase_20 | AC | 48 ms
59,724 KB |
testcase_21 | AC | 609 ms
135,304 KB |
testcase_22 | AC | 494 ms
112,308 KB |
testcase_23 | AC | 600 ms
134,904 KB |
testcase_24 | AC | 417 ms
98,748 KB |
testcase_25 | AC | 589 ms
129,000 KB |
testcase_26 | AC | 598 ms
130,552 KB |
testcase_27 | AC | 139 ms
75,856 KB |
ソースコード
from bisect import bisect_left def acum(List):#累積和 rev = [0 for _ in range(len(List))] for i in range(len(List)): if i == 0: rev[i] = List[i] else: rev[i] = rev[i-1] + List[i] return rev from itertools import product n,S = map(int,input().split()) A = list(map(int,input().split())) if n >= 2: front = [] back = [] for a in A[:n//2]: front .append(a) for a in A[n//2:]: back.append(a) Plist = [] for Ks in product([i for i in range(1,33)],repeat = len(front)): P = 0 for l in range(len(front)): P += pow(front[l],Ks[l]) if P > S: break if P <= S: Plist.append(P) Qlist = [] for Ks in product([i for i in range(1,33)],repeat=len(back)): Q = 0 for l in range(len(back)): Q += pow(back[l],Ks[l]) if Q > S: break if Q <= S: Qlist.append(Q) Plist.sort() Qlist.sort() cntP = [0] * len(set(Plist)) cntQ = [0] * len(set(Qlist)) index = 0 qlist = sorted(list(set(Qlist))) plist = sorted(list(set(Plist))) for p in Plist: if plist[index] == p: cntP[index] += 1 else: index += 1 cntP[index] += 1 index = 0 for q in Qlist: if qlist[index] == q: cntQ[index] += 1 else: index += 1 cntQ[index] += 1 cum = acum(cntQ) ans = 0 for i,p in enumerate(plist): index = bisect_left(qlist,S-p+1) -1 if index == -1: continue ans += cntP[i] * cum[index] print(ans) else: for k in range(1,33): if pow(A[0],k) <= S: pass else: break print(k-1)