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 1821. Biathlon

HelpPlease (Java)
Posted by Testme 18 Mar 2014 00:37
What is wrong with mycode? it is working in mycomputer but failing in test2

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
/**
 * Created by sherxon on 3/17/14.
 */
public class Biathlon {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=Integer.parseInt(in.nextLine());
        String s, name, time;
        Double min, sec;
        int j=0;
        List<String> a= new ArrayList();
        ArrayList<Double> b= new ArrayList();
        int thirty=0;

           for (int i = 0; i <n ; i++) {

               s = in.nextLine();


            name=s.split(" ")[0];

            sec=Double.parseDouble(s.split(" ")[1].split(":")[1])+60*(Double.parseDouble(s.split(" ")[1].split(":")[0]));
               sec+=thirty;
               //System.out.println(sec);
               double eachsec=0.0;
               double eachsecs=0.0;
                boolean bl=true;


               for (int k = 0; k<a.size() ; k++) {
                 //  System.out.println(sec-thirty + " " + (b.get(k)-eachsec) + " " +(sec) + " " + b.get(k));


                   if(sec-thirty<b.get(k)-eachsec&&sec<b.get(k)){
                       b.remove(k);
                       a.remove(k);
                       k--;
                   }
                   eachsec+=30;
               }
               for (int k = 0; k <a.size() ; k++) {
                   if(sec-thirty>b.get(k)-eachsecs){
                       bl=false;
                   }
                   eachsecs+=30;
               }
                if(bl){
               a.add(name);
               b.add(sec);
                }

               thirty+=30;
        }
        Collections.sort(a);
        System.out.println(a.size());

        for (int i = 0; i <a.size() ; i++) {
            System.out.println(a.get(i));
        }
    }
}