Submission #62797452
Source Code Expand
Copy
def divisors(x):small, large = [], []i = 1while i * i <= x:if x % i == 0:small.append(i)if i * i != x:large.append(x // i)i += 1return large + small[::-1]import sysfrom collections import defaultdictinput_data = sys.stdin.read().split()it = 0n = int(input_data[it]); it += 1k = int(input_data[it]); it += 1a = list(map(int, input_data[it:it+n]))mx = max(a)
def divisors(x):
small, large = [], []
i = 1
while i * i <= x:
if x % i == 0:
small.append(i)
if i * i != x:
large.append(x // i)
i += 1
return large + small[::-1]
import sys
from collections import defaultdict
input_data = sys.stdin.read().split()
it = 0
n = int(input_data[it]); it += 1
k = int(input_data[it]); it += 1
a = list(map(int, input_data[it:it+n]))
mx = max(a)
tmp = [0] * (mx + 1)
for x in a:
tmp[x] += 1
mt = [0] * (mx + 1)
for d in range(mx, 0, -1):
s = 0
for i in range(d, mx + 1, d):
s += tmp[i]
mt[d] = s
cache = {}
divs_cache = {}
for ai in a:
if ai in cache:
print(cache[ai])
continue
if ai not in divs_cache:
divs_cache[ai] = divisors(ai)
for d in divs_cache[ai]:
if mt[d] >= k:
cache[ai] = d
print(d)
break
Submission Info
| Submission Time | |
|---|---|
| Task | E - GCD of Subset |
| User | juten |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 0 |
| Code Size | 968 Byte |
| Status | TLE |
| Exec Time | 2233 ms |
| Memory | 410784 KB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 475 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_a_distinct_00.txt, 02_a_distinct_01.txt, 02_a_distinct_02.txt, 02_a_distinct_03.txt, 02_a_distinct_04.txt, 03_a_max_00.txt, 03_a_max_01.txt, 03_a_max_02.txt, 03_a_max_03.txt, 03_a_max_04.txt, 03_a_max_05.txt, 03_a_max_06.txt, 04_hcn_00.txt, 04_hcn_01.txt, 04_hcn_02.txt, 04_hcn_03.txt, 04_hcn_04.txt, 04_hcn_05.txt, 04_hcn_06.txt, 04_hcn_07.txt, 04_hcn_08.txt, 05_corner_00.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 70 ms | 76816 KB |
| 00_sample_01.txt | AC | 70 ms | 76616 KB |
| 00_sample_02.txt | AC | 178 ms | 96192 KB |
| 01_random_00.txt | AC | 1982 ms | 341356 KB |
| 01_random_01.txt | TLE | 2228 ms | 404184 KB |
| 01_random_02.txt | TLE | 2231 ms | 408460 KB |
| 01_random_03.txt | TLE | 2229 ms | 407360 KB |
| 01_random_04.txt | TLE | 2231 ms | 392948 KB |
| 01_random_05.txt | TLE | 2228 ms | 403800 KB |
| 01_random_06.txt | AC | 1994 ms | 349940 KB |
| 01_random_07.txt | TLE | 2228 ms | 396320 KB |
| 01_random_08.txt | TLE | 2233 ms | 382456 KB |
| 01_random_09.txt | TLE | 2227 ms | 370676 KB |
| 02_a_distinct_00.txt | TLE | 2232 ms | 368812 KB |
| 02_a_distinct_01.txt | TLE | 2228 ms | 348044 KB |
| 02_a_distinct_02.txt | TLE | 2230 ms | 373560 KB |
| 02_a_distinct_03.txt | TLE | 2229 ms | 410784 KB |
| 02_a_distinct_04.txt | TLE | 2231 ms | 405432 KB |
| 03_a_max_00.txt | AC | 432 ms | 252428 KB |
| 03_a_max_01.txt | AC | 399 ms | 252628 KB |
| 03_a_max_02.txt | AC | 421 ms | 252220 KB |
| 03_a_max_03.txt | AC | 420 ms | 252084 KB |
| 03_a_max_04.txt | AC | 447 ms | 252692 KB |
| 03_a_max_05.txt | AC | 468 ms | 255676 KB |
| 03_a_max_06.txt | AC | 505 ms | 256156 KB |
| 04_hcn_00.txt | AC | 387 ms | 247720 KB |
| 04_hcn_01.txt | AC | 393 ms | 247484 KB |
| 04_hcn_02.txt | AC | 442 ms | 247356 KB |
| 04_hcn_03.txt | AC | 595 ms | 251988 KB |
| 04_hcn_04.txt | AC | 611 ms | 252084 KB |
| 04_hcn_05.txt | AC | 556 ms | 252128 KB |
| 04_hcn_06.txt | AC | 611 ms | 252136 KB |
| 04_hcn_07.txt | AC | 600 ms | 252388 KB |
| 04_hcn_08.txt | AC | 610 ms | 252272 KB |
| 05_corner_00.txt | AC | 126 ms | 87964 KB |