GCJ Sub Round 1A will start in less than 5 minutes. I hope I will make it in top 800. If not I will have one more chance! Later!
////+++Later Edit++++////
So sub-round 1A is over. And guess what? I made it in top 840 (as required for advancing). My results weren’t that great, but important was to be in top 840. I don’t know exactly how many competed in this sub-round, but I know there were almost 4000 competitors registered at it and only 2394 managed to have non-zero score.
Ok, so here you can find the problems: click here
So let me tell you what I did in contest. So for problem A if you read it you have to minimize sum(x[i], y[i]) i = 0…n where x and y are the two given vectors, and being allowed to permute any of the vector.
For small input I coded quickly a solution with next_permutation as n was very small. But for Large input obvious this solution won’t work. That’s why I did a greedy which worked just fine. The minimal sum was given if you sorted the first vector in decreasing order and the second vector in increasing order. A small thing to be careful was that the sum would not fit on int, so long long was preffered.
For second problem that I read was C because it had a short statement. If you read C you will see that this is a math problem. So if you calculate (3 + sqrt(5)) ^ n is equal with X + Y * sqrt(5). Where X is always calculated modulo 1000 and Y would fit on Long Long. But it looks like still it looses precision. So I failed doing the small-input. Then I tried to find a good precision calculator online, and I decided to use Google Calculator for small (as n <= 30.) But guess what still I failed. After that I just gave up and read problem B. BTW: the solution was based on the fact that (3 + sqrt(5))^N + (3-sqrt(5))^N is an integer and (3-sqrt(5))^N < 1. (I won’t give more details
)
For problem B, I saw the obvious solution (brute force in 2 ^ N, as N <= 10). But for large input I though only a max flow will solve it. But looks like a greedy would work, because there is a small detail in statement telling that a malted shake could be in a list of favorite of a person maxim one time.
For those that will participate in Sub-Round 1B and C, I wish good luck. See you in 2nd Round.
Recent Comments