QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#816237 | #9528. New Energy Vehicle | hxu10# | TL | 15ms | 10652kb | Python3 | 1.1kb | 2024-12-16 05:46:41 | 2024-12-16 05:46:42 |
Judging History
answer
import io,os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import heapq
def main():
n,m = map(int,input().split())
cap = list(map(int,input().split()))
data = []
remain = cap[:]
for _ in range(m):
x,i = map(int,input().split())
data.append((x,i-1))
inf = 10**18
for i in range(n):
data.append((inf+i,i))
m = len(data)
curr = 0
while True:
mind = 2*inf
minpick = -1
for i in range(m):
if data[i][0] == curr:
remain[data[i][1]] = cap[i]
for i in range(m):
if data[i][0] <= curr: continue
if data[i][0] < mind and remain[data[i][1]] > 0:
mind = data[i][0]
minpick = data[i][1]
if minpick < 0:
curr += sum(remain)
break
curr += 1
remain[minpick] -= 1
print(curr)
T = int(input())
t = 1
while t <= T:
main()
t += 1
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 15ms
memory: 10652kb
input:
2 3 1 3 3 3 8 1 2 2 5 2 1 2 2 1
output:
12 9
result:
ok 2 lines
Test #2:
score: -100
Time Limit Exceeded
input:
6 3 2 2 2 2 6 1 7 1 2 2 3 3 2 1 6 2 2 3 2 2 5 1 7 2 9 1 2 2 3 3 2 1 6 2 1 1 999999999 1000000000 1 1 1 1000000000 1000000000 1