QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#345242 | #7933. Build Permutation | yby | Compile Error | / | / | Java11 | 1.3kb | 2024-03-06 17:25:15 | 2024-03-06 17:25:16 |
Judging History
answer
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] a = new int[n + 1];
int[] b = new int[n + 1];
int[] p = new int[n + 1];
int[] s = new int[n + 1];
for (int i = 1; i <= n; i++) {
a[i] = scanner.nextInt();
b[i] = i;
}
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
if (a[b[i]] > a[b[j]]) {
int temp = b[i];
b[i] = b[j];
b[j] = temp;
}
}
}
for (int i = 1; i <= n; i++) {
p[b[i]] = b[n - i + 1];
}
for (int i = 1; i <= n; i++) {
s[i] = a[i] + a[p[i]];
}
boolean flag = true;
for (int i = 2; i <= n; i++) {
if (s[i] != s[i - 1]) {
flag = false;
break;
}
}
if (!flag) {
System.out.println("-1");
return;
}
for (int i = 1; i <= n; i++) {
System.out.print(p[i] + " ");
}
System.out.println();
}
}
Details
Main.java:6: error: cannot find symbol Scanner scanner = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:6: error: cannot find symbol Scanner scanner = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors