-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path22574. 높은 곳으로.java
More file actions
27 lines (23 loc) · 861 Bytes
/
Copy path22574. 높은 곳으로.java
File metadata and controls
27 lines (23 loc) · 861 Bytes
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
for (int t = 0; t < T; t++) {
String[] input = br.readLine().split(" ");
int n = Integer.parseInt(input[0]);
int p = Integer.parseInt(input[1]);
int maxFloor = 0;
for (int i = 1; i <= n; i++) {
maxFloor += i;
if (maxFloor == p) {
// 폭탄이 설치된 층을 피하기 위해 그 층을 넘어간다
maxFloor--;
}
}
System.out.println(maxFloor);
}
}
}