結果
問題 | No.2500 Products in a Range |
ユーザー | mkawa2 |
提出日時 | 2023-10-13 22:04:47 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,726 bytes |
コンパイル時間 | 713 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 70,144 KB |
最終ジャッジ日時 | 2024-09-15 17:46:31 |
合計ジャッジ時間 | 5,352 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
52,096 KB |
testcase_01 | AC | 41 ms
51,968 KB |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | AC | 54 ms
61,952 KB |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | AC | 50 ms
60,544 KB |
testcase_17 | AC | 53 ms
61,824 KB |
testcase_18 | AC | 51 ms
61,440 KB |
testcase_19 | AC | 51 ms
60,544 KB |
testcase_20 | AC | 51 ms
61,568 KB |
testcase_21 | AC | 46 ms
58,624 KB |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | AC | 75 ms
62,336 KB |
testcase_29 | AC | 52 ms
60,928 KB |
testcase_30 | AC | 52 ms
60,672 KB |
testcase_31 | WA | - |
testcase_32 | AC | 42 ms
52,480 KB |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | AC | 40 ms
52,224 KB |
testcase_36 | AC | 41 ms
52,352 KB |
testcase_37 | AC | 40 ms
52,096 KB |
testcase_38 | AC | 41 ms
52,096 KB |
testcase_39 | AC | 41 ms
52,096 KB |
testcase_40 | AC | 41 ms
51,968 KB |
testcase_41 | AC | 40 ms
51,712 KB |
testcase_42 | WA | - |
testcase_43 | AC | 41 ms
51,712 KB |
testcase_44 | AC | 47 ms
58,624 KB |
testcase_45 | AC | 41 ms
52,608 KB |
testcase_46 | AC | 47 ms
59,264 KB |
testcase_47 | RE | - |
testcase_48 | AC | 45 ms
57,600 KB |
testcase_49 | WA | - |
testcase_50 | AC | 50 ms
60,672 KB |
testcase_51 | AC | 52 ms
61,056 KB |
testcase_52 | AC | 51 ms
61,312 KB |
testcase_53 | AC | 48 ms
59,904 KB |
testcase_54 | AC | 41 ms
52,352 KB |
testcase_55 | AC | 49 ms
59,904 KB |
testcase_56 | AC | 48 ms
60,032 KB |
testcase_57 | AC | 50 ms
60,288 KB |
testcase_58 | AC | 48 ms
60,288 KB |
testcase_59 | AC | 51 ms
62,080 KB |
testcase_60 | AC | 41 ms
52,480 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-1): 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(i+1+j+1+z) print(ans)