Saturday, September 17, 2016

CPROM 2016 Q3 Find The Winner

Download Question Here

Change Snippet Background Color
 
import java.util.*;


/**
   Author : Hafiq
   Date :
**/

public class Winner{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      String line = System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      int cases = scan.nextInt();
      
      int max = 0;
      String current = "";
      Event ev = new Event();
      List event = new ArrayList<>();
      for(int x=0;x(){
         @Override
         public int compare(Event e1,Event e2){
            if (e1.gold > e2.gold) {
               return -1;
            } else if (e1.gold < e2.gold) {
               return 1;
            } else {
               return 0;
            }
         }
      });
      
       
      for(Event e:event){
         System.out.println(e.toString());
      }
   }
}

class Event{
      public String name;
      public int gold;
      public int silver;
      public int bronze;
      
      public Event(){}
      
      public Event(String a,int b,int c, int d){
          name = a;
          gold = b;
          silver = c;
          bronze = d;
      }
      
      public String toString(){
         return name+" "+gold+" "+silver+" "+bronze;
      }
   }
 

No comments:

Post a Comment