Submission #1558494
Source Code Expand
import java.util.Scanner; import java.util.stream.IntStream; public class Main{ static IntStream REPS(int v){return IntStream.range(0,v);} static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);} static IntStream INS(int n) {return REPS(n).map(i->getInt());} static Scanner s=new Scanner(System.in); static int getInt(){return Integer.parseInt(s.next());} public static void main(String[]$){ int n=getInt(); int in[]=INS(n).toArray(); int c=0; for(int i=0;i<n-1;++i) if(i>=0){ if(in[i]==i+1) { int buf=in[i]; in[i]=in[i+1]; in[i+1]=buf; --i; ++c; } } System.out.println(c); } }
Submission Info
Submission Time | |
---|---|
Task | D - Derangement |
User | fal_rnd |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 667 Byte |
Status | WA |
Exec Time | 495 ms |
Memory | 51048 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 348 ms | 28372 KB |
0_001.txt | AC | 176 ms | 24148 KB |
0_002.txt | AC | 184 ms | 26576 KB |
0_003.txt | AC | 175 ms | 26192 KB |
1_004.txt | WA | 179 ms | 26708 KB |
1_005.txt | AC | 455 ms | 48816 KB |
1_006.txt | AC | 465 ms | 45592 KB |
1_007.txt | AC | 447 ms | 51048 KB |
1_008.txt | WA | 448 ms | 49240 KB |
1_009.txt | WA | 456 ms | 45592 KB |
1_010.txt | AC | 445 ms | 48608 KB |
1_011.txt | WA | 479 ms | 49360 KB |
1_012.txt | AC | 495 ms | 45624 KB |
1_013.txt | AC | 454 ms | 45520 KB |
1_014.txt | AC | 482 ms | 47740 KB |