Submission #61804733


Source Code Expand

Copy
import math
import pypyjit
pypyjit.set_param("max_unroll_recursion=-1")
def solve():
N,M=map(int,input().split())
P=list(map(int,input().split()))
s=0.0
for x in P:
s+=1.0/x
def can(t):
rc=(t*t)/s
if rc> M:
return False
k=[0]*N
f=[0.0]*N
sf=0
for i in range(N):
v=(t/(P[i]*s))
fv=int(v)
k[i]=fv
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
import math
import pypyjit
pypyjit.set_param("max_unroll_recursion=-1")

def solve():
    N,M=map(int,input().split())
    P=list(map(int,input().split()))
    s=0.0
    for x in P:
        s+=1.0/x
    def can(t):
        rc=(t*t)/s
        if rc> M:
            return False
        k=[0]*N
        f=[0.0]*N
        sf=0
        for i in range(N):
            v=(t/(P[i]*s))
            fv=int(v)
            k[i]=fv
            sf+=fv
            f[i]=v-fv
        r=t-sf
        if r<0: return False
        if r>0:
            idx=sorted(range(N),key=lambda i:f[i],reverse=True)
            for i in range(r):
                k[idx[i]]+=1
        c=0
        for i in range(N):
            c+=P[i]*(k[i]*k[i])
            if c> M: return False
        return c<=M
    l=0
    h=int(math.isqrt(N*M))+2
    ans=0
    while l<=h:
        m=(l+h)//2
        if can(m):
            ans=m
            l=m+1
        else:
            h=m-1
    print(ans)

solve()

Submission Info

Submission Time
Task E - Square Price
User tamakiiiiii
Language Python (PyPy 3.10-v7.3.12)
Score 0
Code Size 1008 Byte
Status WA
Exec Time 2223 ms
Memory 322836 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 475
Status
AC × 2
AC × 12
WA × 1
TLE × 13
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.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, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 57 ms 76616 KB
00_sample_01.txt AC 57 ms 76444 KB
01_random_00.txt TLE 2223 ms 303956 KB
01_random_01.txt TLE 2223 ms 310772 KB
01_random_02.txt TLE 2223 ms 310216 KB
01_random_03.txt TLE 2223 ms 307616 KB
01_random_04.txt TLE 2223 ms 308732 KB
01_random_05.txt TLE 2223 ms 310924 KB
01_random_06.txt TLE 2222 ms 308468 KB
01_random_07.txt TLE 2223 ms 310768 KB
01_random_08.txt TLE 2222 ms 295360 KB
01_random_09.txt TLE 2223 ms 310804 KB
01_random_10.txt AC 221 ms 90332 KB
01_random_11.txt TLE 2223 ms 311296 KB
01_random_12.txt AC 171 ms 87100 KB
01_random_13.txt AC 572 ms 124752 KB
01_random_14.txt WA 1895 ms 286076 KB
01_random_15.txt TLE 2222 ms 301484 KB
01_random_16.txt AC 1496 ms 244176 KB
01_random_17.txt AC 907 ms 177464 KB
01_random_18.txt AC 1994 ms 294484 KB
01_random_19.txt TLE 2223 ms 314228 KB
01_random_20.txt AC 1556 ms 322836 KB
01_random_21.txt AC 645 ms 306380 KB
01_random_22.txt AC 57 ms 76824 KB
01_random_23.txt AC 57 ms 76388 KB


2025-03-24 (Mon)
10:05:59 +00:00