0

I made a java code for Problem 231A 'Team' .
My code:

    import java.util.ArrayList;
    import java.util.Scanner;
     
    public class Log {
        public static void main(String[] args) {
            try {
                // I Swear It works
                Scanner in = new Scanner(System.in);
                int iter = in.nextInt();
                int iii = 0;
                ArrayList<String> n = new ArrayList<String>();
                while (iter != 0) {
                    Scanner inn = new Scanner(System.in);
                    String mm = inn.nextLine();
                    n.add(mm);
                    iter-=1;
                }
                for (int i = 0; i < n.size(); i++) {
                    boolean findings =  n.get(i).length() - n.get(i).replaceAll("1", "").length() >= 2;
                    if (findings) {
                        iii+=1;
                    }else {
                        
                    }
                }
                System.out.println(iii);
            }catch(Exception e) {
                e.printStackTrace();
            }
        }
    }


And it said 'Wrong answer on test 1'
I submitted a code from the internet

    import java.util.Scanner;
    public class Log
    {
        public static void main(String args[])
        {
            Scanner ip = new Scanner(System.in);
            int x=ip.nextInt();
            int ctr=0,s=0;
            int[] a = new int[3];
            int[] b = new int[1001];
            for(int i=1;i<=x;i++)
            {
                for(int j=0;j<=2;j++)
                {
                    a[j]=ip.nextInt();
                    s=a[0]+a[1]+a[2];
                }
                b[i]=s;
                    if(b[i]>=2)
                        ctr++;
            }
            System.out.println(ctr);
        }
    }


And it said 'Accepted'
Links of submissions : The Accepted Code , My Submission

I tested the inputs on eclipse till Test 50 and It gave same output..

0 Answers0