[백준] 9080 PC방요금?

`

  1. 22-8시 -> 0~10시로 바꿔서 생각

  2. 5시 이전이고 300분 이상 남으면 야간 적용. 그 외 모든 경우는 1시간씩 빼면서 시간이 없어질 때까지 계속 요금을 더함


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.io.*;
import java.util.*;

public class Main {
	static int T;
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		T = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();
		StringTokenizer st;
		while(T-->0) {
			int ans=0;
			st = new StringTokenizer(br.readLine());
			String time = st.nextToken();
			int spd = Integer.parseInt(st.nextToken());
			
			st = new StringTokenizer(time,":");
			int h = (Integer.parseInt(st.nextToken())+2)%24;
			int m = Integer.parseInt(st.nextToken());
		
			while(spd>0) {
				if(h<=4&&spd>300) {
					spd-=(600-(h*60+m));
					h=10;
					m=0;
					ans+=5000;
				}else {
					h = (h+1)%24;
					spd-=60;
					ans+=1000;
				}
			}
			sb.append(ans).append("\n");
		}
		System.out.println(sb);
	}

}
updatedupdated2021-05-182021-05-18
Load Comments?