QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#420908 | #6430. Monster Hunter | shaletome | Compile Error | / | / | C++14 | 2.6kb | 2024-05-25 03:13:48 | 2024-05-25 03:13:49 |
Judging History
answer
# Left side, 3rd row, inner desk BYU
from itertools import accumulate
for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
a1=[v==1 for v in a]
a2=[v==2 for v in a]
a3=[v==3 for v in a]
c1=list(accumulate(a1+a1,initial=0))
c2=list(accumulate(a2+a2,initial=0))
c3=list(accumulate(a3+a3,initial=0))
ap=list(accumulate(a,initial=0))
# print(ap)
m=int(input())
for i in range(m*2):
c1.append(c1[-1]+1 if a[i%n]==1 else c1[-1])
c2.append(c2[-1]+1 if a[i%n]==2 else c2[-1])
c2.append(c3[-1]+1 if a[i%n]==3 else c3[-1])
h=list(map(int,input().split()))
th=sum(h)
ta=ap[-1]
ans,th=divmod(th,ta)
for i in range(n+1):
if ap[i] >= th:break
n1=c1[n]*ans+c1[i]
n2=c2[n]*ans+c2[i]
n3=c3[n]*ans+c3[i]
i%=n
lo=0
hi=2*m+n-1
nx=[0]*8
n6=0
for hv in h:
n6+=hv//6
if hv%6==1:
if hv==1:
nx[1]+=1
else:
nx[7]+=1
n6-=1
else:
nx[hv%6]+=1
# print(n6,nx)
def test(n1,n2,n3,nx):
# print(n1,n2,n3)
for j in [2,5]:
ts=min(n2,nx[j])
nx[j-2]+=ts
nx[j]-=ts
n2-=ts
for j in [4,7]:
ts=min(n2//2,nx[j])
nx[j-4]+=ts
nx[j]-=ts
n2-=ts*2
for j in [3,7,5,4]:
ts=min(n3,nx[j])
nx[j-3]+=ts
nx[j]-=ts
n3-=ts
for j in [7,5,4,3,2]:
ts=min(n2,nx[j])
nx[j-2]+=ts
nx[j]-=ts
n2-=ts
for j in [7,6,5,4,3]:
if n1<nx[j]:return False
nx[j-1]+=nx[j]
n1-=nx[j]
nx[j]=0
# print(n1,n2,n3)
# print(nx)
v1=min(n1,nx[1])
n1-=v1
nx[1]-=v1
nx[0]+=v1
v2=min(n1//2,nx[2])
n1-=v2*2
nx[2]-=v2
nx[0]+=v2
v1=min(n2,nx[1])
n2-=v1
nx[1]-=v1
nx[0]+=v1
v1=min(n3,nx[2])
n3-=v1
nx[2]-=v1
nx[0]+=v1
v1=min(n3,nx[1])
n3-=v1
nx[1]-=v1
nx[0]+=v1
# print(n1,n2,n3)
# print(nx)
if any(nx[1:]):return False
return (n1+2*n2+3*n3)>=n6*6
return False
while lo!=hi:
mid=(lo+hi)//2
if test(n1+c1[i+mid]-c1[i],
n2+c2[i+mid]-c2[i],
n3+c3[i+mid]-c3[i], nx.copy()):
hi=mid
# print("hi",hi,mid)
else:
lo=mid+1
# print("lo",lo,mid)
print(ans*n+i+hi)
# print(ans)
Details
answer.code:1:3: error: invalid preprocessing directive #Left 1 | # Left side, 3rd row, inner desk BYU | ^~~~ answer.code:16:7: error: invalid preprocessing directive #print 16 | # print(ap) | ^~~~~ answer.code:46:7: error: invalid preprocessing directive #print 46 | # print(n6,nx) | ^~~~~ answer.code:48:11: error: invalid preprocessing directive #print 48 | # print(n1,n2,n3) | ^~~~~ answer.code:74:11: error: invalid preprocessing directive #print 74 | # print(n1,n2,n3) | ^~~~~ answer.code:75:11: error: invalid preprocessing directive #print 75 | # print(nx) | ^~~~~ answer.code:101:11: error: invalid preprocessing directive #print 101 | # print(n1,n2,n3) | ^~~~~ answer.code:102:11: error: invalid preprocessing directive #print 102 | # print(nx) | ^~~~~ answer.code:113:15: error: invalid preprocessing directive #print 113 | # print("hi",hi,mid) | ^~~~~ answer.code:116:15: error: invalid preprocessing directive #print 116 | # print("lo",lo,mid) | ^~~~~ answer.code:118:7: error: invalid preprocessing directive #print 118 | # print(ans) | ^~~~~ answer.code:4:1: error: ‘from’ does not name a type 4 | from itertools import accumulate | ^~~~