# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
93934 | 2019-01-13T12:31:36 Z | zeyad49 | Teams (CEOI11_tea) | Java 11 | 83 ms | 9900 KB |
import java.io.*; import java.util.*; class Main{ public static void main(String[] args) throws IOException { Scanner sc=new Scanner("tea.*"); 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 82 ms | 9708 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 81 ms | 9728 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 78 ms | 9724 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 78 ms | 9752 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 79 ms | 9900 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 80 ms | 9608 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 73 ms | 9596 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 83 ms | 9664 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 75 ms | 9888 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 73 ms | 9800 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |