공부기록/SWEA

[SWEA] 1284번 수도 요금 경쟁

메델 2023. 10. 19. 14:37
import java.util.Scanner;

public class Solution {
	
	public static void main(String[] args) {
		
		Scanner kb = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		
		int T = kb.nextInt();
		
		for(int i=0; i<T; i++) {
			int P = kb.nextInt();
			int Q = kb.nextInt();
			int R = kb.nextInt();
			int S = kb.nextInt();
			int W = kb.nextInt();
			
			
			int ACharge = W*P;
			int BCharge = 0;
			if(W>R) {
				BCharge = Q+ S*(W-R);
			}else {
				BCharge = Q;
			}
			sb.append("#").append(i+1).append(" ");
			if(ACharge>BCharge) {
				sb.append(BCharge);
			}else {
				sb.append(ACharge);
			}
			
			sb.append('\n');
			
		}
		
		System.out.print(sb.toString());
		
	}

}