2856 | 2023-01-30 13:49:08 | csatoe | Videójáték | python3 | Accepted 100/100 | 423ms | 45708 KiB |
from sys import stdin, stdout
def main():
# beolvasás, - unatkozaá
T = int(stdin.readline())
#a Te intervallumaid
tied=[]
for _ in range(int(stdin.readline())):
tol,ig=map(int, stdin.readline().split())
tied.append(tol) #>=0
tied.append(-ig-1) #<0
VEGE = -2**64
tied.append(VEGE)
# Hano intervallumai
hanoe=[]
for _ in range(int(stdin.readline())):
tol,ig=map(int, stdin.readline().split())
hanoe.append(tol) #>=0
hanoe.append(-ig-1) #<0
hanoe.append(VEGE)
teHely=0
teJatszol=False
hanoHely=0
hanoJatszik=False
egyuttKezdet=0
unatkozasKezdet=0
perc=0
while not(tied[teHely]==VEGE and hanoe[hanoHely]==VEGE):
if abs(tied[teHely])<abs(hanoe[hanoHely]):
if tied[teHely]>=0: # start
if hanoJatszik:
egyuttKezdet=tied[teHely]
else:
unatkozasKezdet=tied[teHely]
teJatszol=True
else: #end
if teJatszol and hanoJatszik:
perc+=-tied[teHely]-egyuttKezdet
teJatszol = False
teHely+=1
else:
if teJatszol and not hanoJatszik and unatkozasKezdet+T < abs(hanoe[hanoHely]):
teJatszol= False
if hanoe[hanoHely]>=0: #start
if teJatszol:
egyuttKezdet = hanoe[hanoHely]
hanoJatszik=True
else: # end
if teJatszol and hanoJatszik:
perc+= -hanoe[hanoHely] - egyuttKezdet
if teJatszol:
unatkozasKezdet = -hanoe[hanoHely]
hanoJatszik = False
hanoHely+=1
stdout.write(str(perc) + '\n')
main()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 17ms | 11532 KiB | ||||
2 | Accepted | 17ms | 11808 KiB | ||||
subtask2 | 10/10 | ||||||
3 | Accepted | 17ms | 12052 KiB | ||||
4 | Accepted | 17ms | 12004 KiB | ||||
5 | Accepted | 17ms | 12144 KiB | ||||
6 | Accepted | 17ms | 12600 KiB | ||||
7 | Accepted | 17ms | 12532 KiB | ||||
8 | Accepted | 17ms | 12608 KiB | ||||
9 | Accepted | 17ms | 12720 KiB | ||||
10 | Accepted | 17ms | 13012 KiB | ||||
11 | Accepted | 17ms | 13148 KiB | ||||
subtask3 | 20/20 | ||||||
12 | Accepted | 17ms | 13036 KiB | ||||
13 | Accepted | 17ms | 13156 KiB | ||||
14 | Accepted | 17ms | 13236 KiB | ||||
15 | Accepted | 18ms | 13456 KiB | ||||
16 | Accepted | 17ms | 13348 KiB | ||||
17 | Accepted | 19ms | 13792 KiB | ||||
18 | Accepted | 19ms | 13732 KiB | ||||
19 | Accepted | 20ms | 13852 KiB | ||||
20 | Accepted | 19ms | 14084 KiB | ||||
21 | Accepted | 19ms | 14080 KiB | ||||
22 | Accepted | 17ms | 13832 KiB | ||||
subtask4 | 30/30 | ||||||
23 | Accepted | 56ms | 17292 KiB | ||||
24 | Accepted | 155ms | 24848 KiB | ||||
25 | Accepted | 377ms | 42128 KiB | ||||
26 | Accepted | 419ms | 45172 KiB | ||||
27 | Accepted | 423ms | 45416 KiB | ||||
28 | Accepted | 180ms | 26572 KiB | ||||
29 | Accepted | 43ms | 16276 KiB | ||||
30 | Accepted | 41ms | 15844 KiB | ||||
31 | Accepted | 30ms | 15092 KiB | ||||
subtask5 | 40/40 | ||||||
32 | Accepted | 54ms | 17220 KiB | ||||
33 | Accepted | 163ms | 26136 KiB | ||||
34 | Accepted | 279ms | 35364 KiB | ||||
35 | Accepted | 365ms | 41996 KiB | ||||
36 | Accepted | 412ms | 45708 KiB | ||||
37 | Accepted | 409ms | 45544 KiB | ||||
38 | Accepted | 252ms | 34568 KiB | ||||
39 | Accepted | 298ms | 38560 KiB | ||||
40 | Accepted | 85ms | 20932 KiB | ||||
41 | Accepted | 123ms | 24056 KiB |