Submission #93935

# Submission time Handle Problem Language Result Execution time Memory
93935 2019-01-13T12:35:36 Z zeyad49 Teams (CEOI11_tea) Java 11
0 / 100
2500 ms 155036 KB
import java.io.*;
import java.util.*;

class tea{

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		int n=sc.nextInt();
		int []a=new int[n];
		Integer[]indices=new Integer[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			indices[i]=i;
		}
		Arrays.sort(indices,Comparator.comparingInt(i->-a[i]));
		
		int min=0;
		
		
		ArrayList<Integer>[]lists=new ArrayList[n];
		int rem=0;
		for(int idx:indices) {
			if(rem==0) {
				rem=a[idx]-1;
				lists[min]=new ArrayList();
				lists[min++].add(idx+1);
			}
			else {
				rem--;
				lists[min-1].add(idx+1);
			}
		}
		out.println(min);
		for(int i=0;i<min;i++)
		{
			out.print(lists[i].size());
			for(int x:lists[i])
			{
				out.print(" ");
				out.print(x);
			}
			out.println();
		}

		out.close();

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}

Compilation message

Note: tea.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
# Verdict Execution time Memory Grader output
1 Correct 181 ms 16072 KB Output is correct
2 Incorrect 196 ms 15604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 208 ms 15916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 194 ms 15696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 262 ms 17448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 264 ms 17096 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 539 ms 37672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 563 ms 39804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2037 ms 129716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2617 ms 155036 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2520 ms 122988 KB Time limit exceeded
2 Halted 0 ms 0 KB -