# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
381143 | 2021-03-24T16:22:55 Z | vijay | Triumphal arch (POI13_luk) | Java 11 | 2000 ms | 75412 KB |
import java.io.*; import java.util.*; public class luk { static int N; static int[] dayCount; static ArrayList<Integer>[] adj; public static void main(String[] args) throws IOException, FileNotFoundException { Scanner in = new Scanner(System.in); // PrintWriter out = new PrintWriter("luk.out"); N = in.nextInt(); dayCount = new int[N]; adj = new ArrayList[N]; for(int i = 0; i < N; i++){ adj[i] = new ArrayList<>(); } for(int i = 0; i < N - 1; i++){ int a = in.nextInt() - 1; int b = in.nextInt() - 1; adj[a].add(b); adj[b].add(a); } recurse(0, 0, -1); // System.out.println(Arrays.toString(dayCount)); // System.out.println(works(2)); int a = 0; int b = N - 1; while(a != b){ int mid = (a + b)/2; if(works(mid)){ b = mid; } else { a = mid + 1; } } System.out.println(a); } static boolean works(int count){ int[] at = new int[count]; int pos = 0; for(int dayPos = 1; dayPos < N; dayPos++){ for(int city = 0; city < dayCount[dayPos]; city++){ if(at[pos] >= dayPos){ return false; } at[pos]++; pos++; pos%=count; } } return true; } static void recurse(int position, int day, int prev){ dayCount[day]++; for(int ap: adj[position]){ if(ap != prev){ recurse(ap, day + 1, position); } } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 131 ms | 10712 KB | Output is correct |
2 | Correct | 162 ms | 10476 KB | Output is correct |
3 | Incorrect | 173 ms | 10416 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 159 ms | 10196 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 213 ms | 10992 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 360 ms | 13776 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 758 ms | 19580 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 886 ms | 22248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1338 ms | 36288 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1910 ms | 54760 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2052 ms | 72408 KB | Time limit exceeded |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2060 ms | 75412 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |