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 1964. Chinese Dialects

WA #13, what's the issue?
Posted by Holykill (AUA) 3 Dec 2014 21:31
so what is the trick with the test 13? Here is my code:

public static void main(String[] args) {
            Scanner input = new Scanner(System.in);
            int n = input.nextInt();
            int k = input.nextInt();
            long[] arr = new long[k];
            long first = 20000000000000L;
            int first_location = 0;
            long second = 2000000000000L;
            for (int i = 0; i < k; i++)
                arr[i] = input.nextInt();

            for (int i = 0; i < k; i++)
                if (arr[i] < first)
                {
                    first = arr[i];
                    first_location = i;
                }
            arr[first_location] = 0;

            for (int i = 0; i < k; i++)
                if (arr[i] < second && arr[i] != 0)
                    second = arr[i];
            long answer = first + second - n;
            if (answer > 0)
                System.out.println(answer);
            else System.out.println(0);

    }