|
|
вернуться в форумWrong answer 32 import java.io.*; import java.util.*; //import java.math.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); //String[] name = new String[6]; String[] device = new String[6]; int[] price = new int[6]; Map<String,Integer> result = new TreeMap<String,Integer>(); Map<String,Integer> rprice = new TreeMap<String,Integer>();
for(int i=0; i<6; i++) { in.readLine(); device[i] = in.readLine(); price[i] = Integer.parseInt(in.readLine());
if(!result.containsKey(device[i])) { result.put(device[i],1); rprice.put(device[i],price[i]); } else { result.put(device[i],result.get(device[i])+1); if(price[i]<rprice.get(device[i])) rprice.put(device[i],price[i]); } } int rep = 1, max = 1; for(int i : new ArrayList<Integer>(result.values())) { if(max==i) rep++; if(max<i) { rep = 1; max = i; } }
if(rep==1) { for(String i : result.keySet()) if(max==result.get(i)) out.print(i); } else { int min=0; for(String i : rprice.keySet()) { if(max==result.get(i)) { if(min==0) min=rprice.get(i); else if(min>=rprice.get(i)) min=rprice.get(i); } } for(String i : rprice.keySet()) { if(min==rprice.get(i)) out.print(i); } } out.flush(); } } |
|
|