About Problem B (Startup), Dictionary in Python Hack

Правка en2, от Mostafa_Alaa99, 2024-11-03 17:21:38

Again, someone hacked my B solution coz of the Python Dictionary (this can happen also when using CPP unordered_map)

But I noticed that it can be done using an array because the constraint bi <= k which will allow to avoid Py dict

So, I wonder did the problem setter put this constraint for Python users to be able to solve it also in Python as they can avoid dictionary because of it, or the constraint exists for any other reason?

UPD1: Now, I have used d[str(key)] = value and it works and got ACC not TLE like the previous

Submission: 289783097 ~~~~~ brands = defaultdict(int) for _ in range(k): bi, ci = read_numbers() brands[str(bi)] += ci

brands = list(brands.values()) brands.sort(reverse=True) ans = 0 for i in range(min(n, len(brands))): ans += brands[i]

print(ans) ~~~~~

the only change is the str(bi) instead of bi, can anyone try to hack it or show me something that will let this not work

coz I really wants to use Python all time (recursion problem has no idea how to solve it yet, but I am speaking now about this problem)

Теги hacking, contest, hashmap, constraint

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский Mostafa_Alaa99 2024-11-03 17:39:00 231
en3 Английский Mostafa_Alaa99 2024-11-03 17:22:30 4 Tiny change: '9783097]\n~~~~~\nb' -> '9783097]\n\n\n~~~~~\nb'
en2 Английский Mostafa_Alaa99 2024-11-03 17:21:38 675
en1 Английский Mostafa_Alaa99 2024-11-03 11:49:47 492 Initial revision (published)