Advertisement
abhisekp

CodinGame - The Descent

Jan 31st, 2015
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1.         // game loop
  2.         while (true) {
  3.             int SX = in.nextInt();
  4.             int SY = in.nextInt();
  5.             int max = 0;
  6.             int maxI = 0;
  7.             for (int i = 0; i < 8; i++) {
  8.                 int MH = in.nextInt(); // represents the height of one mountain, from 9 to 0. Mountain heights are provided from left to right.
  9.  
  10.                 if(MH > max) {
  11.                     max = MH;
  12.                     maxI = i;
  13.                     System.err.println("Max = " + max);
  14.                 }
  15.             }
  16.  
  17.             if(SX == maxI) {
  18.                 System.out.println("FIRE"); // either:  FIRE (ship is firing its phase cannons) or HOLD (ship is not firing).
  19.             } else {
  20.                 System.out.println("HOLD");
  21.             }
  22.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement