Advertisement
xTheEc0

CodinGame.com // The Descent // Easy

Oct 22nd, 2015
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. /**
  9.  * Auto-generated code below aims at helping you parse
  10.  * the standard input according to the problem statement.
  11.  **/
  12. int main()
  13. {
  14.  
  15.     // game loop
  16.     while (1) {
  17.         int spaceX;
  18.         int spaceY;
  19.         int mountainH; // represents the height of one mountain, from 9 to 0. Mountain heights are provided from left to right.
  20.         cin >> spaceX >> spaceY; cin.ignore();
  21.         int max_id = 0;
  22.         int max_h = 0;
  23.        
  24.         for (int i = 0; i < 8; i++)
  25.         {
  26.             cin >> mountainH; cin.ignore();
  27.             if (mountainH > max_h)
  28.             {
  29.                 max_id = i;
  30.                 max_h = mountainH;
  31.             }
  32.         }
  33.        
  34.         // Write an action using cout. DON'T FORGET THE "<< endl"
  35.         // To debug: cerr << "Debug messages..." << endl;
  36.    
  37.        
  38.         cout << (spaceX == max_id ? "FIRE" : "HOLD") << endl; // either:  FIRE (ship is firing its phase cannons) or HOLD (ship is not firing).
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement