개발자 톡
테케 1,8,9번 틀리는데 반례좀 찾아주실 분 계신가요ㅠㅠ
- 등록일
- 2024-05-24 11:46:08
- 조회수
- 274
- 작성자
- cabin4nam
import java.io.*;
import java.util.*;
public class Main {
private static class Elevator{
int length;
int speed;
public Elevator(int length, int speed){
this.length = length;
this.speed = speed;
}
}
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
Elevator[] info = new Elevator[N];
for(int i=0; i<N; i++){
st = new StringTokenizer(br.readLine());
info[i] = new Elevator(Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken()));
}
int answer = 0;
int testArea = 0;
for(int i=0; i<M; i++){
st = new StringTokenizer(br.readLine());
int testLen = Integer.parseInt(st.nextToken());
int testSpeed = Integer.parseInt(st.nextToken());
while(testLen > 0){
if(testArea >= info.length) break;
// 속도 위반 검사
if(info[testArea].speed < testSpeed){
int diff = testSpeed - info[testArea].speed;
if(diff > answer) answer = diff;
}
testLen -= info[testArea].length;
if(testLen <=0) testArea ++;
}
}
System.out.println(answer);
}
}