File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments