-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path31631.java
More file actions
35 lines (31 loc) · 875 Bytes
/
Copy path31631.java
File metadata and controls
35 lines (31 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// https://www.acmicpc.net/problem/31631
// :rightplant:
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
static int n, arr[];
public static void main(String[] args) throws IOException {
BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt(scan.readLine());
arr = new int[n];
int val = n;
for(int i=0; i<n/2; i++){
if(i%2 == 0){
arr[n-1-i] = val--;
arr[i] = val--;
}
else{
arr[i] = val--;
arr[n-1-i] = val--;
}
}
if(n%2 == 1)
arr[n/2] = 1;
StringBuilder sb = new StringBuilder();
for(int i=0; i<n; i++){
sb.append(arr[i]).append(' ');
}
System.out.println(sb);
}
}