

























其中0<T<=10, 0<X<=100, 0<S<=10000, 0<n<=10, 0<m<=1000,所有员工的姓名都由大写字母组成,不为空且长度不超过10。
2 20 4 3 61 A B C B 2 39 A B A 4 88 A B C D C 3 40 B C D B 15 4 3 61 A B C B 2 39 A B A 4 88 A B C D C 3 40 B C D B
A 39 B 100 C 80 A 30 B 85 C 60
郁闷,超时
1 import java.util.Scanner;
2 import java.util.*;
3 public class Main {
4 public static void main(String[] args) {
5 Scanner in = new Scanner(System.in);
6 int zu = in.nextInt();
7 String result ="";
8 for(int i=0;i<zu;i++)
9 {
10 Hashtable<String,Integer> haTable= new Hashtable<String,Integer>();
11 int X = in.nextInt();
12 int s = in.nextInt();
13 ArrayList<String> list = new ArrayList<String>();
14 for(int j=0;j<s;j++)
15 {
16 int count = in.nextInt();
17 int total = in.nextInt();
18 String pmaney = "";
19 for(int k = 0;k<=count;k++)
20 {
21 pmaney = in.next();
22 }
23 if(!list.contains(pmaney))list.add(pmaney);
24 if(total>X*count)
25 total = X*count;
26 if(haTable.containsKey(pmaney))
27 haTable.put(pmaney,haTable.get(pmaney)+total);
28 else
29 haTable.put(pmaney,total);
30 }
31
32 String[] keys = new String[list.size()];
33 list.toArray(keys);
34 Arrays.sort(keys);
35 for(int j=0;j<keys.length;j++)
36 {
37 result += keys[j]+ " "+ haTable.get(keys[j])+"\n";
38 }
39 result+="\n";
40 }
41 System.out.println(result);
42 }
43 }
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。