結果
| 問題 |
No.702 中央値を求めよ LIMITED
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-08 13:58:02 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,027 bytes |
| コンパイル時間 | 240 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 24,640 KB |
| 最終ジャッジ日時 | 2024-09-08 13:58:15 |
| 合計ジャッジ時間 | 12,876 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 1 -- * 1 |
| other | -- * 25 |
ソースコード
## https://yukicoder.me/problems/no/702
import heapq
MAX = 2 ** 32 - 1
class Generator:
def __init__(self, seed):
self.x = seed
self.y = 1
self.z = 2
self.w = 3
def generate(self):
t = (self.x ^ (self.x << 11)) & MAX
self.x = self.y
self.y = self.z
self.z = self.w
self.w = ((self.w ^ (self.w >> 19)) ^ (t ^ (t >> 8))) & MAX
return self.w
def solve(N, seed, value):
generator = Generator(seed)
n2 = N // 2
n1 = n2 + 1
cnt = 0
for _ in range(N):
x = generator.generate()
if x >= value:
cnt += 1
return cnt >= n1
def main():
seed = int(input())
N = 10000001
low = 0
high = 2 ** 32 - 1
while high - low > 1:
mid = (high + low ) // 2
if solve(N, seed, mid):
low = mid
else:
high = mid
if solve(N, seed, high):
print(high)
else:
print(low)
if __name__ == "__main__":
main()