結果
| 問題 |
No.1537 私の代わりに仕事やっといてください。
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-06-07 12:59:42 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 1,841 ms / 2,000 ms |
| コード長 | 1,884 bytes |
| コンパイル時間 | 3,314 ms |
| コンパイル使用メモリ | 85,504 KB |
| 実行使用メモリ | 57,192 KB |
| 最終ジャッジ日時 | 2024-11-26 18:21:27 |
| 合計ジャッジ時間 | 6,798 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 9 |
ソースコード
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner();
int n = sc.nextInt();
City[] cities = new City[n];
for (int i = 0; i < n; i++) {
cities[i] = new City(i + 1, sc.nextInt());
}
Arrays.sort(cities);
ArrayList<City> deq = new ArrayList<>();
for (int i = 0; i < n; i++) {
if (i % 2 == 0) {
deq.add(0, cities[i]);
} else {
deq.add(cities[i]);
}
}
for (int i = 0; i < n; i++) {
if (deq.get(i).idx > 1) {
continue;
}
StringBuilder sb = new StringBuilder();
for (int j = 0; j < n; j++) {
sb.append(deq.get((i + j) % n).idx).append(" ");
}
sb.append(1);
System.out.println(sb);
return;
}
}
static class City implements Comparable<City> {
int idx;
int value;
public City(int idx, int value) {
this.idx = idx;
this.value = value;
}
public int compareTo(City another) {
return value - another.value;
}
}
}
class Scanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
public Scanner() throws Exception {
}
public int nextInt() throws Exception {
return Integer.parseInt(next());
}
public long nextLong() throws Exception {
return Long.parseLong(next());
}
public String next() throws Exception {
if (!st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
}
tenten