Submission #625435
Source Code Expand
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = Integer.parseInt(sc.next());
int p = 0; //pointer
int turn = 0;
int ai = 0;
List<Integer> list = new ArrayList<Integer>(N);
List<Integer> sorted = new ArrayList<Integer>(N);
while (sc.hasNext()) {
int n = Integer.parseInt(sc.next());
list.add(n);
sorted.add(n);
}
Collections.sort(sorted);
do{
turn++;
ai = sorted.get(p);
// 一周分
for (int i = 0; i < N; i++) {
int current = list.get(i);
if (current == ai) {
// System.out.println(current);
p++;
if(p < N){
ai = sorted.get(p); // 更新
}
else break;
}
}
// 最後に一番目の部屋を見る
int current = list.get(0);
if (current == ai) {
// System.out.println(current);
p++;
if(p < N){
ai = sorted.get(p); // 更新
}
else break;
}
}while(p < N);
System.out.println(turn);
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - ディスコ社内ツアー |
| User | tk3fftk |
| Language | Java8 (OpenJDK 1.8.0) |
| Score | 0 |
| Code Size | 1145 Byte |
| Status | WA |
| Exec Time | 2048 ms |
| Memory | 48344 KiB |
Judge Result
| Set Name | Sample | Small | Permutation | All | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 20 | 0 / 10 | 0 / 70 | ||||||||||||||||
| Status |
|
|
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt |
| Small | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 20_perm_01.txt, 20_perm_02.txt, 20_perm_03.txt, 20_perm_04.txt, 20_perm_05.txt, 20_perm_06.txt, 20_perm_07.txt, 20_perm_08.txt, 30_hand_01.txt, 30_hand_02.txt, 30_hand_03.txt, 30_hand_04.txt, 30_hand_05.txt, 30_hand_06.txt |
| Permutation | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 20_perm_01.txt, 20_perm_02.txt, 20_perm_03.txt, 20_perm_04.txt, 20_perm_05.txt, 20_perm_06.txt, 20_perm_07.txt, 20_perm_08.txt, 30_hand_01.txt, 30_hand_02.txt, 60_perm_01.txt, 60_perm_02.txt, 60_perm_03.txt, 60_perm_04.txt, 60_perm_05.txt, 60_perm_06.txt, 60_perm_07.txt, 60_perm_08.txt, 70_hand_01.txt, 70_hand_02.txt |
| All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 20_perm_01.txt, 20_perm_02.txt, 20_perm_03.txt, 20_perm_04.txt, 20_perm_05.txt, 20_perm_06.txt, 20_perm_07.txt, 20_perm_08.txt, 30_hand_01.txt, 30_hand_02.txt, 30_hand_03.txt, 30_hand_04.txt, 30_hand_05.txt, 30_hand_06.txt, 50_rand_01.txt, 50_rand_02.txt, 50_rand_03.txt, 50_rand_04.txt, 50_rand_05.txt, 50_rand_06.txt, 50_rand_07.txt, 50_rand_08.txt, 60_perm_01.txt, 60_perm_02.txt, 60_perm_03.txt, 60_perm_04.txt, 60_perm_05.txt, 60_perm_06.txt, 60_perm_07.txt, 60_perm_08.txt, 70_hand_01.txt, 70_hand_02.txt, 70_hand_03.txt, 70_hand_04.txt, 70_hand_05.txt, 70_hand_06.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_example_01.txt | AC | 667 ms | 29188 KiB |
| 00_example_02.txt | AC | 649 ms | 29092 KiB |
| 00_example_03.txt | AC | 546 ms | 28956 KiB |
| 00_example_04.txt | AC | 478 ms | 29056 KiB |
| 10_rand_01.txt | WA | 546 ms | 29072 KiB |
| 10_rand_02.txt | AC | 403 ms | 29088 KiB |
| 10_rand_03.txt | AC | 473 ms | 28944 KiB |
| 10_rand_04.txt | AC | 882 ms | 29040 KiB |
| 10_rand_05.txt | AC | 692 ms | 29148 KiB |
| 10_rand_06.txt | AC | 513 ms | 29188 KiB |
| 10_rand_07.txt | AC | 486 ms | 28984 KiB |
| 10_rand_08.txt | AC | 443 ms | 29056 KiB |
| 20_perm_01.txt | AC | 476 ms | 29132 KiB |
| 20_perm_02.txt | AC | 537 ms | 29100 KiB |
| 20_perm_03.txt | AC | 618 ms | 28912 KiB |
| 20_perm_04.txt | AC | 473 ms | 28968 KiB |
| 20_perm_05.txt | AC | 531 ms | 28996 KiB |
| 20_perm_06.txt | AC | 483 ms | 29144 KiB |
| 20_perm_07.txt | AC | 552 ms | 29152 KiB |
| 20_perm_08.txt | AC | 521 ms | 28924 KiB |
| 30_hand_01.txt | AC | 595 ms | 29008 KiB |
| 30_hand_02.txt | AC | 501 ms | 29048 KiB |
| 30_hand_03.txt | AC | 547 ms | 29188 KiB |
| 30_hand_04.txt | AC | 473 ms | 29092 KiB |
| 30_hand_05.txt | AC | 482 ms | 28952 KiB |
| 30_hand_06.txt | AC | 470 ms | 29092 KiB |
| 50_rand_01.txt | AC | 1593 ms | 43916 KiB |
| 50_rand_02.txt | TLE | 2041 ms | 46040 KiB |
| 50_rand_03.txt | TLE | 2048 ms | 45816 KiB |
| 50_rand_04.txt | TLE | 2041 ms | 44256 KiB |
| 50_rand_05.txt | AC | 986 ms | 42736 KiB |
| 50_rand_06.txt | AC | 485 ms | 29352 KiB |
| 50_rand_07.txt | AC | 735 ms | 38464 KiB |
| 50_rand_08.txt | TLE | 2041 ms | 45616 KiB |
| 60_perm_01.txt | TLE | 2042 ms | 43532 KiB |
| 60_perm_02.txt | TLE | 2042 ms | 46472 KiB |
| 60_perm_03.txt | TLE | 2042 ms | 46020 KiB |
| 60_perm_04.txt | TLE | 2041 ms | 45336 KiB |
| 60_perm_05.txt | AC | 1865 ms | 42432 KiB |
| 60_perm_06.txt | AC | 539 ms | 29400 KiB |
| 60_perm_07.txt | AC | 1078 ms | 38092 KiB |
| 60_perm_08.txt | TLE | 2042 ms | 46804 KiB |
| 70_hand_01.txt | AC | 1662 ms | 46592 KiB |
| 70_hand_02.txt | TLE | 2043 ms | 47248 KiB |
| 70_hand_03.txt | AC | 890 ms | 47612 KiB |
| 70_hand_04.txt | AC | 837 ms | 46764 KiB |
| 70_hand_05.txt | TLE | 2045 ms | 48344 KiB |
| 70_hand_06.txt | AC | 1780 ms | 47452 KiB |