๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm

[๋ฐฑ์ค€] 12790๋ฒˆ: Mini Fantasy War(๊ตฌํ˜„)

by ์ฃผ๋ฐœ2 2020. 5. 24.
๋ฐ˜์‘ํ˜•

https://www.acmicpc.net/problem/12790

 

12790๋ฒˆ: Mini Fantasy War

๋„ฅ์Šจ์ง€ํ‹ฐ์—์„œ๋Š” ์ตœ๊ทผ SRPG "์Šˆํผ ํŒํƒ€์ง€ ์›Œ"์˜ ํ›„์†์ž‘์œผ๋กœ "๋ฏธ๋‹ˆ ํŒํƒ€์ง€ ์›Œ"๋ฅผ ์ถœ์‹œํ•˜์˜€๋‹ค. ์ „ํŽธ๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ, ๋ฏธ๋‹ˆ ํŒํƒ€์ง€ ์›Œ์—์„œ๋„ ๊ฐ ์บ๋ฆญํ„ฐ์˜ ์ „ํˆฌ๋ ฅ์„ ๊ณ„์‚ฐํ•˜์—ฌ์•ผ ํ•œ๋‹ค. ๊ฐ ์บ๋ฆญํ„ฐ์˜ ์ „ํˆฌ๋ ฅ

www.acmicpc.net

์ฝ”๋“œ

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		
		int T = Integer.parseInt(bf.readLine()); // ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์˜ ์ˆ˜
		for(int i=0; i<T; i++) {
			st = new StringTokenizer(bf.readLine());
			int[] ability = new int[8];	// HP, MP ๊ณต, ๋ฐฉ, ์ฆ๊ฐ๋˜๋Š” HP, MP, ๊ณต, ๋ฐฉ
			for(int j=0; j<8; j++) {
				ability[j] = Integer.parseInt(st.nextToken());
			}
			
			// ์ตœ์ข… ๋Šฅ๋ ฅ์น˜ = ๊ธฐ๋ณธ ๋Šฅ๋ ฅ์น˜ + ์žฅ๋น„ ๋Šฅ๋ ฅ์น˜
			for(int j=0; j<4; j++) {
				ability[j] += ability[j+4];
			}
			
			// HP, MP๊ฐ€ 1๋ณด๋‹ค ์ž‘์€๊ฒฝ์šฐ 1๋กœ ๊ฐ„์ฃผ, ๊ณต๊ฒฉ๋ ฅ์€ 0๋ณด๋‹ค ์ž‘์€๊ฒฝ์šฐ 0์œผ๋กœ ๊ฐ„์ฃผ
			ability[0] = (ability[0] < 1) ? 1 : ability[0];
			ability[1] = (ability[1] < 1) ? 1 : ability[1];
			ability[2] = (ability[2] < 0) ? 0 : ability[2];
			
			// ์ „ํˆฌ๋ ฅ = 1 * (HP) + 5 * (MP) + 2 * (๊ณต๊ฒฉ๋ ฅ) + 2 * (๋ฐฉ์–ด๋ ฅ)
			int result = ability[0] + (ability[1]*5) + (ability[2]*2) + (ability[3]*2);
			System.out.println(result);
		}
		bf.close();
	}

}

ํ’€์ด

๋ฌธ์ œ์— ๋”ฐ๋ผ์„œ ๊ทธ๋Œ€๋กœ ๊ตฌํ˜„ํ•˜๋ฉด ๋œ๋‹ค!

ํ•ด๋‹น ์ •๋ณด๋ฅผ ๋ฐฐ์—ด๋กœ ์ž…๋ ฅ๋ฐ›๊ณ , ์ฃผ์–ด์ง„ ์กฐ๊ฑด์—๋”ฐ๋ผ ๊ตฌํ˜„..

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€