반응형
https://www.acmicpc.net/problem/2460
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String[] args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int[][] train=new int[10][2];
int Max=0,tmp=0;
for(int i=0;i<10;i++) {
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
train[i][0]=Integer.parseInt( st.nextToken() );//내린사람
train[i][1]=Integer.parseInt( st.nextToken() );//탄사람
}
Max=tmp=train[0][1]; //처음 탄 사람
for(int i=1;i<10;i++) {
tmp=(tmp-train[i][0])+train[i][1];
if(Max<=tmp) {
Max=tmp;
}
}
System.out.println(Max);
}
}
728x90
반응형
'코딩테스트 > 백준' 카테고리의 다른 글
백준 2309 Java 자바 (0) | 2022.08.02 |
---|---|
백준 10870 Java (0) | 2022.08.02 |
백준 2460 Java (0) | 2022.08.01 |
백준 2501 Java (0) | 2022.08.01 |
백준 2751 Java (0) | 2022.07.22 |
댓글