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 的用法

时间: 2024-12-29 23:54:50

Pokemon Master的相关文章

ZOJ 3776: Pokemon Master

ZOJ - 3776 ///@author Sycamore, ZJNU ///@submitted_on 2017 - 01 - 17 /// #include<iostream> using namespace std; int main() { int T; cin >> T; while (T--) { int N, M, w1 = 0, w2 = 0, t; cin >> N >> M; while (N--) { cin >> t;

Gotta Catch Em&#39; All!

Gotta Catch Em' All! Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination turned into an obsession. Since he i

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined) A

Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination turned into an obsession. Since he is too young to go out

reset master和reset slave命令解析和区别

reset master删除所有index file 中记录的所有binlog 文件,将日志索引文件清空,创建一个新的日志文件,这个命令通常仅仅用于第一次用于搭建主从关系的时的主库, 注意: reset master 不同于purge binary log的两处地方1.reset master 将删除日志索引文件中记录的所有binlog文件,创建一个新的日志文件 起始值从000001 开始,然而purge binary log 命令并不会修改记录binlog的顺序的数值2.reset maste

kubernetes Master部署之Scheduler 以及 HA部署(5)

Kubernetes Scheduler作用是将Controller Manager将要新建的Pod按照特定的调度算法和调度策略绑定到集群中某个合适的Node上,并将绑定信息写入到etcd中. 一.部署Scheduler 下面生成kube-scheduler的kubeconfig文件,操作如下: cd /etc/kubernetes export KUBE_APISERVER="https://192.168.15.200:6443" 配置 cluster kubectl config

nis master的yppasswdd

yppasswdd是nis master特有的,用于和slave进行同步(即push的方式,包括yppasswd密码更新) 操作: master: # /usr/lib/yp/ypinit -m 所有从nis服务器 # service ypserv restart # service yppasswdd restart 有2个关键点: 1是ypinit -m 写上所有nis从服务器 2是需重启yppasswdd服务

2015南阳CCPC A - Secrete Master Plan 水题

D. Duff in Beach Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Master Mind KongMing gave Fei Zhang a secrete master plan stashed in a pocket. The plan instructs how to deploy soldiers on the four corners of the city wall. Unfortunately, w

Spark的Master和Worker集群启动的源码分析

基于spark1.3.1的源码进行分析 spark master启动源码分析 1.在start-master.sh调用master的main方法,main方法调用 def main(argStrings: Array[String]) { SignalLogger.register(log) val conf = new SparkConf val args = new MasterArguments(argStrings, conf) val (actorSystem, _, _, _) =

Git 的origin和master分析

首先要明确一点,对git的操作是围绕3个大的步骤来展开的(其实几乎所有的SCM都是这样) 1.     从git取数据(git clone) 2.     改动代码 3.     将改动传回git(git push) 这3个步骤又涉及到两个repository,一个是remote repository,再远程服务器上,一个是local repository,再自己工作区上.其中 1, 3两个步骤涉及到remote server/remote repository/remote branch, 2