You should fully trust the input data and avoid those checking for bounds.

Also, DO NOT output something like "Input:" or "Output:" unless the problem
statement ask you to do so.

See this code for example:

import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N;
        N = s.nextInt();
        int C[] = new int[N];
        int l[] = new int[N];
        int P[][] = new int[N][2000];
        for (int j = 0; j < N; j++) {
            C[j] = s.nextInt();
            l[j] = s.nextInt();
            for (int i = 0; i < l[j]; i++) {
                P[j][i] = s.nextInt();
            }
        }
        int g = 0;
        for (int k = 0; k < N; k++) {
            for (int i = 0; i < l[k]; i++) {
                for (int j = 0; j < l[k]; j++) {
                    if (i != j) {
                        if (C[k] == P[k][i] + P[k][j]) {
                            System.out.println("Case #" + (k + 1) + ":
" + (i + 1) + " " + (j + 1));
                            g = 1;
                            break;
                        }
                    }
                }
                if (g == 1) {
                    break;
                }
            }
            g = 0;
        }
        s.close();
    }}


Also, available here <http://ideone.com/Ym2ZIU>.

Xiongqi

Kakon <[email protected]>于2016年1月27日周三 上午11:17写道:

> On Monday, January 18, 2016 at 6:18:38 PM UTC-8, Xiongqi ZHANG wrote:
> > > my solution seems about right but i don´t understand why they say it
> is incorrect. maybe i´m uploading the file the wrong way?
> > >
> > > To solve the problem i used C and created a file as the answer and
> then uploaded that file.
> >
> > There must be something wrong with your code and I can't help if you
> don't provide me your source code.
>
> I have also faced the same problem. Here is my source code. Can you please
> tell me what's the problem?
>
> package storecredit;
> import java.util.Scanner;
> public class StoreCredit {
>
>     public static void main(String[] args) {
>         Scanner s=new Scanner(System.in);
>         int N;
>         System.out.println("Input");
>         N=s.nextInt();
>         int C[]=new int[N];
>         int l[]=new int[N];
>         int P[][]=new int[N][98];
>         if(N<=10&&N>=1){
>           for(int j=0;j<N;j++){
>             C[j]=s.nextInt();
>             l[j]=s.nextInt();
>           if(C[j]>=5&&C[j]<=1000){
>             if(l[j]>=3&&l[j]<=100){
>                 for(int i=0;i<l[j];i++){
>                     P[j][i]=s.nextInt();
>                 }
>             }
>           }
>           }
>         }
>        int g=0;
>        System.out.println("Output:");
>        for(int k=0;k<N;k++){
>         for(int i=0;i<l[k];i++){
>             for(int j=0;j<l[k];j++){
>                 if(i!=j){
>                 if(C[k]==P[k][i]+P[k][j]){
>                     System.out.println("Case #"+(k+1)+": "+(i+1)+"
> "+(j+1));
>                     g=1;
>                     break;
>                 }
>                 }
>             }
>             if(g==1){
>                 break;
>             }
>         }
>         g=0;
>     }
>     }
>
> }
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/1f8845cc-d986-440f-bb13-3c3d26bbda60%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAGDEU-LB12jyQCKqxvhcSwpV-Sh3HYpOQB0SQpW70f%3D6wQBHjw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to