結果
問題 | No.1929 Exponential Sequence |
ユーザー | lilictaka |
提出日時 | 2022-05-21 12:06:19 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,819 bytes |
コンパイル時間 | 203 ms |
コンパイル使用メモリ | 82,508 KB |
実行使用メモリ | 135,976 KB |
最終ジャッジ日時 | 2024-09-20 11:26:50 |
合計ジャッジ時間 | 13,965 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
53,504 KB |
testcase_01 | AC | 45 ms
58,624 KB |
testcase_02 | AC | 90 ms
76,244 KB |
testcase_03 | AC | 587 ms
131,076 KB |
testcase_04 | AC | 1,081 ms
76,160 KB |
testcase_05 | AC | 43 ms
56,960 KB |
testcase_06 | AC | 38 ms
52,480 KB |
testcase_07 | AC | 136 ms
76,288 KB |
testcase_08 | AC | 39 ms
52,096 KB |
testcase_09 | AC | 95 ms
75,904 KB |
testcase_10 | AC | 44 ms
57,088 KB |
testcase_11 | AC | 140 ms
76,032 KB |
testcase_12 | TLE | - |
testcase_13 | AC | 1,199 ms
76,288 KB |
testcase_14 | TLE | - |
testcase_15 | AC | 1,095 ms
76,596 KB |
testcase_16 | AC | 127 ms
76,288 KB |
testcase_17 | AC | 43 ms
56,320 KB |
testcase_18 | AC | 38 ms
52,864 KB |
testcase_19 | AC | 37 ms
52,608 KB |
testcase_20 | AC | 45 ms
59,776 KB |
testcase_21 | AC | 576 ms
135,976 KB |
testcase_22 | AC | 454 ms
112,888 KB |
testcase_23 | AC | 556 ms
135,428 KB |
testcase_24 | AC | 386 ms
98,984 KB |
testcase_25 | AC | 545 ms
129,440 KB |
testcase_26 | AC | 564 ms
130,936 KB |
testcase_27 | AC | 140 ms
76,132 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)