File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ ```java
2+ import java.io.*;
3+ import java.util.*;
4+
5+ public class Main {
6+ public static void main(String[] args) throws IOException {
7+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8+ StringTokenizer st;
9+
10+ int N = Integer.parseInt(br.readLine());
11+ int[] resultList = new int[N];
12+ int[] answerList = new int[N];
13+
14+ st = new StringTokenizer(br.readLine());
15+ for(int i = 0; i < N; i++) {
16+ resultList[i] = Integer.parseInt(st.nextToken());
17+ }
18+
19+ answerList[0] = resultList[0];
20+ int idx = answerList[0] % N;
21+
22+ for(int i = 1; i < N; i++) {
23+ while(answerList[idx] != 0) {
24+ idx = (idx + 1) % N;
25+ }
26+ answerList[idx] = resultList[i];
27+ idx = (idx + resultList[i]) % N;
28+ }
29+
30+ System.out.println(N);
31+ for(int x : answerList) {
32+ System.out.print(x + " ");
33+ }
34+ }
35+ }
36+ ```
You can’t perform that action at this time.
0 commit comments