반응형
    
    
    
  https://www.acmicpc.net/problem/1637
1637번: 날카로운 눈
문제 동물원에서 막 탈출한 원숭이 한 마리가 세상구경을 하고 있다. 그 원숭이는 좀 특이한 원숭이였다. 어떤 것도 꿰뚫어볼 수 있는 날카로운 눈을 가진 기이한 원숭이였다. 부드러운 눈을 가진 멍멍이는 언제나 날카로운 눈을 가진 원숭이를 부러워했지만 한편으로는 매우 질투했다. 어느 날 멍멍이는 원숭이의 날카로운 눈이 너무 샘나서 원숭이를 직접 패고 싶었지만 날카로운 눈으로 찌를까봐 무서워서 때리지는 못하고 대신, 원숭이에게 문제 하나를 던져주었다. 그 문제
www.acmicpc.net
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | package algo; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B1637 {     static int N;     static long A, B, C;     static class Three {         long A;         long B;         long C;         public Three(long a, long b, long c) {             super();             A = a;             B = b;             C = c;         }     }     static Three tc[];     public static void main(String[] args) throws NumberFormatException, IOException {         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));         StringTokenizer st;         N = Integer.parseInt(br.readLine());         long rear = 1;         long front = 1;         tc = new Three[N];         for (int i = 0; i < N; i++) {             st = new StringTokenizer(br.readLine());             A = Long.parseLong(st.nextToken());             C = Long.parseLong(st.nextToken());             B = Long.parseLong(st.nextToken());             tc[i] = new Three(A, B, C);             rear = Math.max(rear, C);         }         long end = rear;         while (front < rear) {             long mid = (front + rear) / 2;             long cnt = f(mid);             if (cnt % 2 == 1) {                 rear = mid;             } else {                 front = mid + 1;             }         }         if (rear == end && f(rear)%2==0) {             System.out.println("NOTHING");         } else {             System.out.println(rear + " " + (f(rear) - f(rear - 1)));         }     }     public static long f(long x) {         long cnt = 0L;         for (int i = 0; i < N; i++) {             long y = x > tc[i].C ? tc[i].C : x;             if ((y - tc[i].A) >= 0) {                 cnt += 1 + (y - tc[i].A) / tc[i].B;             }         }         return cnt;     } } http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter | 
반응형
    
    
    
  'ProgramSoliving' 카테고리의 다른 글
| 백준 : 7682 (0) | 2020.04.15 | 
|---|---|
| 백준 : 10775 (0) | 2020.04.15 | 
| 백준 : 5213 JAVA (0) | 2020.03.17 | 
| 백준 : 12886 (0) | 2020.03.15 | 
| 백준 : 1086 JAVA (0) | 2020.03.14 |