본문 바로가기
GAME/www.codingame.com

OnBoarding

by 므시칸곰틔군 2015. 2. 9.

import java.util.*;

import java.io.*;

import java.math.*;


/**

 * The code below will read all the game information for you.

 * On each game turn, information will be available on the standard input, you will be sent:

 * -> the total number of visible enemies

 * -> for each enemy, its name and distance from you

 * The system will wait for you to write an enemy name on the standard output.

 * Once you have designated a target:

 * -> the cannon will shoot

 * -> the enemies will move

 * -> new info will be available for you to read on the standard input.

 **/

class Player {


    public static void main(String args[]) {

        Scanner in = new Scanner(System.in);

        // game loop

        while (true) {

            

            String MainEnemy =null;

            int setDist = 1000;

            

            int count = in.nextInt(); // The number of current enemy ships within range

            

            for (int i = 0; i < count; i++) {

              

                String enemy = in.next(); // The name of this enemy

                int dist = in.nextInt(); // The distance to your cannon of this enemy


                 if(dist < setDist){

                     setDist = dist;

                     MainEnemy = enemy;

                 }

                 

            }

            // Write an action using System.out.println()

            // To debug: System.err.println("Debug messages...");


            System.out.println(MainEnemy); // The name of the most threatening enemy (HotDroid is just one example)

             

          

        }

    }

}


끝까지 되는데 왜 되는지 모르겠음.

'GAME > www.codingame.com' 카테고리의 다른 글

Temperatures  (0) 2015.02.11
Skynet: the Chasm  (0) 2015.02.10
Power of Thor  (0) 2015.02.10
The Descent  (0) 2015.02.09