abyboi's blog

By abyboi, history, 3 years ago, In English

This is the problem I have been trying to solve:

https://codeforces.com/contest/1539/problem/D

This was my attempted solution:

https://codeforces.com/contest/1539/submission/120232784

The attempt was inspired from the tutorial — Sorting b_i and using a custom two pointer technique for buying multiple products at once. However, it is failing test #8 and I don't know what is the reason (I think that maybe some integer overflow/a small bug is present otherwise my approach is correct). If someone could guide me on how to go about this that'd be great!

  • Vote: I like it
  • -6
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Check your function sortbysec(const pi &a, const pi &b) -> This is causing integer overflow. Use pll in place of pi.