Submission #62795180
Source Code Expand
Copy
def divisors(x):divs = []i = 1while i*i <= x:if x % i == 0:divs.append(i)if i*i != x:divs.append(x//i)i += 1return divsn,k=map(int,input().split())a=list(map(int,input().split()))from collections import defaultdictmx=max(a)tmp=[0]*(mx+1)for x in a:tmp[x]+=1mt=[0]*(mx+1)for d in range(mx,0,-1):
def divisors(x):
divs = []
i = 1
while i*i <= x:
if x % i == 0:
divs.append(i)
if i*i != x:
divs.append(x//i)
i += 1
return divs
n,k=map(int,input().split())
a=list(map(int,input().split()))
from collections import defaultdict
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=defaultdict(int)
for ai in a:
if ai in cache:
print(cache[ai])
div=divisors(ai)
div.sort(reverse=True)
flg=1
for d in div:
if mt[d]>=k:
cache[ai]=d
flg=0
print(cache[ai])
break
if flg:
cache[ai]=1
print(1)
Submission Info
| Submission Time | |
|---|---|
| Task | E - GCD of Subset |
| User | juten |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 0 |
| Code Size | 850 Byte |
| Status | TLE |
| Exec Time | 2232 ms |
| Memory | 286628 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 | 76 ms | 77152 KB |
| 00_sample_01.txt | AC | 76 ms | 76888 KB |
| 00_sample_02.txt | AC | 247 ms | 95968 KB |
| 01_random_00.txt | TLE | 2219 ms | 218752 KB |
| 01_random_01.txt | TLE | 2222 ms | 273136 KB |
| 01_random_02.txt | TLE | 2224 ms | 264844 KB |
| 01_random_03.txt | TLE | 2222 ms | 272744 KB |
| 01_random_04.txt | TLE | 2223 ms | 238780 KB |
| 01_random_05.txt | TLE | 2222 ms | 273104 KB |
| 01_random_06.txt | TLE | 2220 ms | 218148 KB |
| 01_random_07.txt | TLE | 2222 ms | 272932 KB |
| 01_random_08.txt | TLE | 2224 ms | 228056 KB |
| 01_random_09.txt | TLE | 2222 ms | 273036 KB |
| 02_a_distinct_00.txt | TLE | 2226 ms | 275768 KB |
| 02_a_distinct_01.txt | TLE | 2227 ms | 276876 KB |
| 02_a_distinct_02.txt | TLE | 2226 ms | 275968 KB |
| 02_a_distinct_03.txt | TLE | 2223 ms | 279348 KB |
| 02_a_distinct_04.txt | TLE | 2226 ms | 276964 KB |
| 03_a_max_00.txt | TLE | 2229 ms | 273256 KB |
| 03_a_max_01.txt | TLE | 2222 ms | 273336 KB |
| 03_a_max_02.txt | TLE | 2230 ms | 273336 KB |
| 03_a_max_03.txt | TLE | 2228 ms | 273588 KB |
| 03_a_max_04.txt | TLE | 2224 ms | 273240 KB |
| 03_a_max_05.txt | TLE | 2232 ms | 286396 KB |
| 03_a_max_06.txt | TLE | 2231 ms | 286628 KB |
| 04_hcn_00.txt | TLE | 2225 ms | 273004 KB |
| 04_hcn_01.txt | TLE | 2226 ms | 273000 KB |
| 04_hcn_02.txt | TLE | 2225 ms | 273304 KB |
| 04_hcn_03.txt | TLE | 2225 ms | 273128 KB |
| 04_hcn_04.txt | TLE | 2225 ms | 273316 KB |
| 04_hcn_05.txt | TLE | 2225 ms | 273084 KB |
| 04_hcn_06.txt | TLE | 2226 ms | 272964 KB |
| 04_hcn_07.txt | TLE | 2227 ms | 273048 KB |
| 04_hcn_08.txt | TLE | 2228 ms | 273300 KB |
| 05_corner_00.txt | AC | 120 ms | 88148 KB |