Pokemon Master

Pokemon Master

Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other)
Total Submission(s) : 15   Accepted Submission(s) : 8
Problem Description
Calem and Serena are pokemon masters. One day they decided to have a pokemon battle practice before Pokemon World Championships. Each of them has some pokemons in each's team. To make the battle more interesting, they decided to use a special rule to determine the winner: the team with heavier total weight will win the battle!
Input
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:
The first line contains two integers N and M (1 <= N, M <= 6), which describes that Calem has N pokemons and Serena has M pokemons.
The second line contains N integers indicating the weight of Calem's pokemons. The third line contains M integers indicating the weight of Serena's pokemons. All pokemons' weight are in the range of [1, 2094] pounds.
Output
For each test case, output "Calem" if Calem's team will win the battle, or "Serena" if Serena's team will win. If the two team have the same total weight, output "Draw" instead.
Sample Input
1
6 6
13 220 199 188 269 1014
101 176 130 220 881 396
Sample Output
Serena
 
package ACM1;


import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Scanner;



public class nyojw2
{
  public static void main(String[]args)
  {
      Scanner scanner = new Scanner(System.in);
      int t = scanner.nextInt();
      for(int i=0;i<t;i++)
      {
         int n = scanner.nextInt();
         int m = scanner.nextInt();
         int sum1=0;
         int sum2=0;
         for(int j=0;j<n;j++)
         {
             sum1=sum1+scanner.nextInt();
             
         }
         for(int j=0;j<m;j++)
         {
             
             sum2=sum2+scanner.nextInt();
         }
         if(sum1==sum2)
             System.out.println("Draw");
         if(sum1<sum2)
             System.out.println("Serena");
         if(sum1>sum2)
             System.out.println("Calem");
          
      }
      
  }
}

当java的数组用不明白的时候减少用数组的频率,因当学一下ArryList 的用法

posted on 2015-04-21 20:55  盒子先生金金  阅读(561)  评论(0编辑  收藏  举报

导航