|
|
вернуться в форумHint This problem can be solved using brute force. The asymptotics is O(n*2^n) but still the time limit is not hit, provided you use bit operations instead of generating arrays. For you beginners, I post my code here, but I strongly recommend to write this on your own first. The language I use is Java; nextInt() function returns the next integer from the input. [code deleted] Worst time is 0.187 sec, as reported by Timus. Edited by moderator 21.10.2019 22:59 Re: Hint Hi ! Would you mind explaining the if on the second for ? I mean, how is this putting all different combination of blocks on each pile ? Thanks :D Re: Hint man u're awesome :) solution is great for that kinda bruteforce! just made all those things in cpp myself and got ACd :D but this problem's still far too hard for the "beginners" tag on which it is right now :) Re: Hint Can anybody translate me this code on C++ or Pascal Re: Hint Thanks, got AC converting it into C++. |
|
|