31112023-02-16 10:05:47fanibarkaiBenzinkút üzemeltetés (55)python3Wrong answer 3/5521ms13820 KiB
from sys import stdin, stdout
n, k = stdin.readline().split()
n = int(n)
k = int(k)
ta = dict(
      stdin.readline().split()
      for _ in range(n)
)
tn = list(ta)
ta = dict(sorted(ta.items(), key=lambda x:x[1], reverse = True))
os = [0]

for key, val in ta.items():
      t = int(key)
      os.append(tn.index(key)+1)
      os[0] = int(val)
      for ke, va in ta.items():
            if t != int(ke):
                  if int(ke) - t >= k or int(ke) - t <= -(k):
                        t = int(ke)
                        os.append(tn.index(ke)+1)
                        os[0] += int(va)

                  else:
                        stdout.write(str(os[0])+ "\n")
                        os.pop(0)
                        os = sorted(os)
                        print(len(os), *os)
                        exit()
                  
SubtaskSumTestVerdictTimeMemory
base3/55
1Accepted0/017ms11532 KiB
2Wrong answer0/021ms12324 KiB
3Wrong answer0/317ms11768 KiB
4Accepted3/317ms11992 KiB
5Wrong answer0/317ms12244 KiB
6Wrong answer0/317ms12752 KiB
7Wrong answer0/317ms12796 KiB
8Wrong answer0/317ms12904 KiB
9Wrong answer0/317ms13264 KiB
10Wrong answer0/317ms13356 KiB
11Wrong answer0/317ms13252 KiB
12Wrong answer0/319ms13428 KiB
13Wrong answer0/419ms13356 KiB
14Wrong answer0/419ms13812 KiB
15Wrong answer0/521ms13816 KiB
16Wrong answer0/619ms13668 KiB
17Wrong answer0/619ms13820 KiB