You are not logged in. Please login at www.codechef.com to post your questions!

×

the lead game ..why it is giving wrong answer..?

import java.io.*;
//import java.io.BufferedOutputStream;
//import java.io.BufferedReader;
//import java.io.IOException;
//import java.io.InputStreamReader;
//import java.io.PrintWriter;

class Main {
public static void main(String[] args) throws NumberFormatException, IOException {

BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));     
PrintWriter pr=new PrintWriter(new BufferedOutputStream(System.out));   
int k=Integer.parseInt(bu.readLine());
int a[]=new int[k];
int b[]=new int[k];
int l;
for(l=0;l<=k-1;l++)
{
    String n=bu.readLine();
    String s[]=n.split(" ");

    a[l]=Integer.parseInt(s[0]);    
b[l]=Integer.parseInt(s[1]);
}

//int sum1=0,sum2=0;
int max1=a[0]-b[0],max2=b[0]-a[0];
for(l=0;l<k;l++)
{
if(a[l]>b[l])
{
    if( (a[l]-b[l]) > max1)
    {
    max1=a[l]-b[l];
    }   
    }

if(b[l]>a[l])
{
    if( (b[l]-a[l]) > max2)
    {
    max2=b[l]-a[l];
    }   
    }       
}

if(max1 > max2)
{
    pr.print("1 "+ max1);   
}
    else if(max2>max1)
    {
        pr.print("2 "+ max2);   
    }

pr.close();
    }

}

asked 18 Oct '14, 12:00

yash_5's gravatar image

0★yash_5
212
accept rate: 0%

edited 18 Oct '14, 12:28

topcoder_7's gravatar image

2★topcoder_7
2.9k3153

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×148
×138
×30
×24
×16
×9
×3
×2

question asked: 18 Oct '14, 12:00

question was seen: 549 times

last updated: 18 Oct '14, 12:28