Skip to content

Commit 1b2be6d

Browse files
authored
Create 백준_27940_가지산사태.java
1 parent 0a61261 commit 1b2be6d

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import java.util.*;
2+
import java.io.*;
3+
public class Main {
4+
static int[] farm;
5+
public static void main(String[] args) throws IOException {
6+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
StringTokenizer st = new StringTokenizer(br.readLine()," ");
8+
int N = Integer.parseInt(st.nextToken());
9+
int M = Integer.parseInt(st.nextToken());
10+
long K = Integer.parseInt(st.nextToken());
11+
12+
long firstFloor =0;
13+
boolean check = true;
14+
15+
for(int i=0; i<M; i++){
16+
st = new StringTokenizer(br.readLine()," ");
17+
int ti = Integer.parseInt(st.nextToken());
18+
int ri = Integer.parseInt(st.nextToken());
19+
20+
if(check){ //1층이 반드시 먼저 무너짐
21+
firstFloor += ri;
22+
if(firstFloor>K){
23+
System.out.print(i+1+" "+1);
24+
check=false;
25+
}
26+
}
27+
}
28+
if (check) {
29+
System.out.print(-1);
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)