Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

TLG - Wrong Answer

$
0
0
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class test {


    public static void main(String[] args) throws Exception {
        int lines;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];

        int p1,p2,win=0,lead=0;

        lines = Integer.parseInt(br.readLine());

        while(lines-->0)
        {
            str = br.readLine().split(" ");

            p1 = Integer.parseInt(str[0]);
            p2 = Integer.parseInt(str[1]);

            if(p1>p2)
            {

               if(p1-p2>lead)
               {
                   lead=p1-p2;
                   win=1;
               }


            }
            else
            {

                 if(p2-p1>lead)
               {
                  lead=p2-p1;
                   win=2;
               }
            }

        }

        System.out.println(win+" "+lead);

    }
}

why is it giving wrong answer in codechef ??


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>