ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1795. Husband in a Shop

Admins, please check test 8 for submission 4909253 on Java
Posted by d3m0n1c 19 Apr 2013 04:13
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
Re: Admins, please check test 8 for submission 4909253 on Java
Posted by Alexey Dergunov [Samara SAU] 20 Apr 2013 21:20
I think that the problem is in the function swap() which doesn't work in Java.
Re: Admins, please check test 8 for submission 4909253 on Java
Posted by d3m0n1c 27 Apr 2013 00:39
Your guess is wrong. I wrote swap method. Also I used my own hashing. Maybe this is the root cause.