結果
問題 | No.2500 Products in a Range |
ユーザー | mkawa2 |
提出日時 | 2023-10-13 22:09:32 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,728 bytes |
コンパイル時間 | 205 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 63,360 KB |
最終ジャッジ日時 | 2024-09-15 17:51:48 |
合計ジャッジ時間 | 4,742 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
51,712 KB |
testcase_01 | AC | 39 ms
52,224 KB |
testcase_02 | AC | 40 ms
52,736 KB |
testcase_03 | AC | 40 ms
52,272 KB |
testcase_04 | AC | 41 ms
51,968 KB |
testcase_05 | AC | 40 ms
52,736 KB |
testcase_06 | AC | 39 ms
52,480 KB |
testcase_07 | AC | 47 ms
60,800 KB |
testcase_08 | AC | 49 ms
62,592 KB |
testcase_09 | AC | 40 ms
52,528 KB |
testcase_10 | AC | 49 ms
61,952 KB |
testcase_11 | AC | 50 ms
61,824 KB |
testcase_12 | AC | 50 ms
61,184 KB |
testcase_13 | AC | 40 ms
52,608 KB |
testcase_14 | AC | 51 ms
63,360 KB |
testcase_15 | AC | 40 ms
52,992 KB |
testcase_16 | AC | 46 ms
61,184 KB |
testcase_17 | AC | 48 ms
61,440 KB |
testcase_18 | AC | 47 ms
61,184 KB |
testcase_19 | AC | 47 ms
60,672 KB |
testcase_20 | AC | 49 ms
61,824 KB |
testcase_21 | AC | 43 ms
59,392 KB |
testcase_22 | AC | 50 ms
62,336 KB |
testcase_23 | AC | 48 ms
62,464 KB |
testcase_24 | AC | 49 ms
62,336 KB |
testcase_25 | AC | 49 ms
61,952 KB |
testcase_26 | AC | 48 ms
62,464 KB |
testcase_27 | AC | 49 ms
62,592 KB |
testcase_28 | AC | 71 ms
62,208 KB |
testcase_29 | AC | 49 ms
61,804 KB |
testcase_30 | AC | 46 ms
61,312 KB |
testcase_31 | WA | - |
testcase_32 | AC | 40 ms
52,608 KB |
testcase_33 | AC | 50 ms
61,568 KB |
testcase_34 | AC | 48 ms
62,336 KB |
testcase_35 | AC | 39 ms
52,480 KB |
testcase_36 | AC | 39 ms
52,224 KB |
testcase_37 | AC | 38 ms
52,736 KB |
testcase_38 | AC | 38 ms
52,480 KB |
testcase_39 | AC | 39 ms
51,840 KB |
testcase_40 | AC | 39 ms
52,608 KB |
testcase_41 | AC | 39 ms
52,480 KB |
testcase_42 | AC | 39 ms
52,608 KB |
testcase_43 | AC | 39 ms
52,480 KB |
testcase_44 | AC | 43 ms
58,880 KB |
testcase_45 | AC | 40 ms
51,968 KB |
testcase_46 | AC | 47 ms
59,392 KB |
testcase_47 | AC | 50 ms
62,592 KB |
testcase_48 | AC | 42 ms
57,856 KB |
testcase_49 | WA | - |
testcase_50 | AC | 47 ms
61,320 KB |
testcase_51 | AC | 48 ms
61,696 KB |
testcase_52 | AC | 48 ms
61,568 KB |
testcase_53 | AC | 45 ms
60,032 KB |
testcase_54 | AC | 38 ms
52,352 KB |
testcase_55 | AC | 46 ms
60,160 KB |
testcase_56 | AC | 46 ms
60,800 KB |
testcase_57 | AC | 46 ms
60,928 KB |
testcase_58 | AC | 45 ms
60,416 KB |
testcase_59 | AC | 47 ms
61,440 KB |
testcase_60 | AC | 39 ms
52,864 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = -1-(-1 << 31) inf = -1-(-1 << 63) # md = 10**9+7 md = 998244353 def f(pos): arr = [0]*z+pos if not arr: return 0 n = len(arr) i = 0 while i+1 < n and arr[i]*arr[i+1] < l: i += 1 j = n-1 while j-1 >= 0 and arr[j]*arr[j-1] > r: j -= 1 return max(j-i+1, 1) n, l, r = LI() aa = LI() pos = [] neg = [] z = 0 for a in aa: if a < 0: neg.append(a) elif a > 0: pos.append(a) else: z += 1 pos.sort() neg.sort(reverse=True) # pos[2,3,5,6] # neg[-1,-2,-4,-5,-7] if r < 0: for a in pos: for b in neg: if l <= a*b <= r: print(2) exit() ans = 1 elif l >= 0 or not neg or not pos: ans = max(f(pos), f(neg)) else: n, m = len(pos), len(neg) j = m-1 ans = max(f(pos), f(neg)) for i in range(n): if i and pos[i-1]*pos[i] > r: break while j-1 >= 0 and neg[j]*neg[j-1] > r or j >= 0 and neg[j]*pos[i] < l: j -= 1 if j < 0: break ans = max(ans,i+1+j+1+z) print(ans)