소프티어 lv.3 Hanyang Popularity Exceeding Competition
알고리즘/java 2025. 4. 15. 22:17import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int result = 0;
for (int i = 0; i < n; i++) {
if(incresedPopular(br.readLine().split(" "), result)) result++;
}
System.out.println(result);
}
public static boolean incresedPopular(String[] arr, int popularity) {
return Math.abs(Integer.parseInt(arr[0]) - popularity) <= Integer.parseInt(arr[1]);
}
}
https://softeer.ai/practice/9495
만나는 사람의 순서는 바뀌지 않으므로
철민이의 현재 인기도와 유명인의 인기도의 차이의 절대값과 친화력을 비교해서
철민이의 인기도를 1씩 증가시켜나가면 된다.
[백트래킹] 백준 15650번 N과 M (2) [Java] (1) | 2025.04.17 |
---|---|
[백트래킹] 백준 15649번 N과 M (1) [Java] (0) | 2025.04.17 |
소프티어 lv.3 Pipelined (1) | 2025.04.13 |
[다이내믹 프로그래밍] 백준 1697번 숨바꼭질 [Java] (0) | 2025.04.09 |
[다이내믹 프로그래밍] 백준 1753번 최단경로 [Java] (0) | 2025.04.09 |