Submission #143078

#TimeUsernameProblemLanguageResultExecution timeMemory
143078model_codeArranging Shoes (IOI19_shoes)Java
30 / 100
193 ms12524 KiB
public class shoes {
    public long count_swaps(int[] S)
    {
        int current = 0, opposite = 0;
        long swaps = 0;
        while (current < S.length) {
            while (S[current] + S[opposite] != 0) {
                opposite++;
            }
            int newSwaps = opposite - current - (S[current] < 0 ? 1 : 0);
            swaps += newSwaps;
            if (newSwaps > 0) {
                S[opposite] = S[opposite - 1];
            }
            current += 2;
            opposite++;
        }
        return swaps;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...