Submission #329389

# Submission time Handle Problem Language Result Execution time Memory
329389 2020-11-21T00:43:35 Z updown1 Carnival (CEOI14_carnival) Java 11
0 / 100
156 ms 11336 KB
import java.util.Scanner;
 
public class carnival {
 
	public static int[] top;
	public static Scanner scanner;
	public static void main(String[] args) {
		
		scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		top = new int[n];
		int[] ans = new int[n];
		int c = 0;
		for(int i=0; i<n; i++) {
			
			for(int j=0; j<=i; j++) {
				System.out.print((j+1)+" ");
			}
			
			int tc = scanner.nextInt();
			
			if(tc>c) {
				c = tc;
				ans[tc-1]++;
				top[tc-1] = i+1;
			}
			else {
				
				int a = 0;
				int b = c;
				
				while(a!=b) {
					int mid = (a+b/2);
					boolean num = works(mid);
					if(num) {
						b = mid;
					}
					else {
						a = mid+1;
					}
					//System.out.println(mid+" "+num+" "+i);
				}
				//System.out.println(a+" a");
				ans[a]++;
				//System.out.println(ans[a]);
			}
			
		}
		
		for(int i=0; i<n; i++) {
			System.out.println(ans[i]);
		}
 
	}
	
	public static boolean works(int mid) {
		
		for(int i=0; i<=mid; i++) {
			System.out.print((i+1)+" ");
		}
		
		int c = scanner.nextInt();
		
		return c==(mid+1);
		
	}
 
}
# Verdict Execution time Memory Grader output
1 Execution timed out 155 ms 11336 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 156 ms 11180 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 155 ms 10992 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 151 ms 11116 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 152 ms 11136 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -