結果
問題 | No.180 美しいWhitespace (2) |
ユーザー | 👑 rin204 |
提出日時 | 2023-11-23 19:03:41 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,743 bytes |
コンパイル時間 | 133 ms |
コンパイル使用メモリ | 82,328 KB |
実行使用メモリ | 77,056 KB |
最終ジャッジ日時 | 2024-09-26 08:17:46 |
合計ジャッジ時間 | 4,434 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
51,712 KB |
testcase_01 | AC | 33 ms
52,352 KB |
testcase_02 | AC | 32 ms
51,712 KB |
testcase_03 | AC | 33 ms
52,352 KB |
testcase_04 | AC | 58 ms
65,024 KB |
testcase_05 | AC | 60 ms
68,224 KB |
testcase_06 | AC | 64 ms
70,272 KB |
testcase_07 | AC | 68 ms
70,912 KB |
testcase_08 | AC | 75 ms
72,960 KB |
testcase_09 | AC | 123 ms
73,984 KB |
testcase_10 | AC | 121 ms
73,728 KB |
testcase_11 | AC | 84 ms
76,032 KB |
testcase_12 | AC | 95 ms
75,776 KB |
testcase_13 | AC | 124 ms
76,124 KB |
testcase_14 | AC | 131 ms
76,032 KB |
testcase_15 | AC | 124 ms
74,496 KB |
testcase_16 | AC | 127 ms
75,952 KB |
testcase_17 | AC | 121 ms
74,240 KB |
testcase_18 | AC | 118 ms
74,496 KB |
testcase_19 | AC | 121 ms
74,356 KB |
testcase_20 | AC | 35 ms
52,096 KB |
testcase_21 | AC | 34 ms
52,224 KB |
testcase_22 | AC | 33 ms
52,224 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 38 ms
52,096 KB |
testcase_26 | AC | 35 ms
52,224 KB |
testcase_27 | AC | 36 ms
52,352 KB |
testcase_28 | AC | 36 ms
51,712 KB |
testcase_29 | AC | 37 ms
52,352 KB |
testcase_30 | AC | 199 ms
77,056 KB |
testcase_31 | AC | 204 ms
76,564 KB |
testcase_32 | AC | 374 ms
76,160 KB |
testcase_33 | AC | 253 ms
76,800 KB |
testcase_34 | AC | 266 ms
76,440 KB |
ソースコード
n = int(input()) if n == 1: print(0) exit() A = [0] * n B = [0] * n for i in range(n): B[i], A[i] = map(int, input().split()) mi = [None] * n ma = [None] * n for i in range(n): l = 1 r = 1 << 60 for j in range(n): if i == j: continue if A[i] == A[j]: if B[i] > B[j]: r = -1 break elif A[i] > A[j]: r = min(r, (B[j] - B[i]) // (A[i] - A[j])) else: db = B[i] - B[j] da = A[j] - A[i] l = max(l, (db + da - 1) // da) if l <= r: mi[i] = (l, r) l = 1 r = 1 << 60 for j in range(n): if i == j: continue if A[i] == A[j]: if B[i] < B[j]: r = -1 break elif A[i] > A[j]: da = A[i] - A[j] db = B[j] - B[i] l = max(l, (db + da - 1) // da) else: r = min(r, (B[i] - B[j]) // (A[j] - A[i])) if l <= r: ma[i] = (l, r) ans = 1 << 60 x = 1 << 60 for i in range(n): if mi[i] is None: continue l1, r1 = mi[i] for j in range(n): if i == j or ma[j] is None: continue l2, r2 = ma[j] cand = [] if l1 <= r2 <= r1: cand.append(r2) if l1 <= l2 <= r1: cand.append(l2) if l2 <= l1 <= r2: cand.append(l1) if l2 <= r1 <= r2: cand.append(r1) for c in cand: ma_ = A[j] * c + B[j] mi_ = A[i] * c + B[i] if ma_ - mi_ < ans: ans = ma_ - mi_ x = c elif ma_ - mi_ == ans and c < x: x = c print(x)