|
|
вернуться в форумOr give me some tests please. All tests that were proposed on the forum shows correct result. The main loop is: while (head != n) { if (id[head] != -1) { int have = shop[id[head]].count; if (have > 0) { if (want[head] > have) { if (head == n - 1) { ++time; break; } swap(id[head], id[head + 1]); swap(want[head], want[head + 1]); want[head + 1] = have; } else { shop[id[head]].count = have - want[head]; ++head; } } else ++head; } else ++head; ++time; } Edited by author 19.04.2013 14:14 Edited by author 19.04.2013 14:14 I think that the problem is in the function swap() which doesn't work in Java. Your guess is wrong. I wrote swap method. Also I used my own hashing. Maybe this is the root cause. |
|
|