Submission #1452769
Source Code Expand
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; public class Main { public static void main(String[] args) throws IOException { BufferedReader tec = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); for (String line; (line = tec.readLine()) != null;) { int n=Integer.parseInt(line.trim()); int[]arr=new int[n]; HashMap<Integer, Boolean>bool=new HashMap<>(); for (int i = 0; i < n; i++){ arr[i]=Integer.parseInt(tec.readLine().trim()); bool.put(arr[i], (i&1)==1); } Arrays.sort(arr); int cont=0; for (int i = 0; i < arr.length; i++) { if((i&1)==0==bool.get(arr[i])){ cont++; } } out.println(cont>>1); } out.close(); } }
Submission Info
Submission Time | |
---|---|
Task | C - BBuBBBlesort! |
User | vjudge1 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 600 |
Code Size | 862 Byte |
Status | AC |
Exec Time | 297 ms |
Memory | 48920 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 294 ms | 44840 KB |
02.txt | AC | 230 ms | 38004 KB |
03.txt | AC | 242 ms | 48920 KB |
04.txt | AC | 297 ms | 45784 KB |
05.txt | AC | 241 ms | 38620 KB |
06.txt | AC | 206 ms | 37532 KB |
07.txt | AC | 224 ms | 36552 KB |
08.txt | AC | 186 ms | 35636 KB |
09.txt | AC | 179 ms | 36916 KB |
10.txt | AC | 178 ms | 38516 KB |
11.txt | AC | 193 ms | 37108 KB |
12.txt | AC | 212 ms | 36236 KB |
13.txt | AC | 198 ms | 37588 KB |
14.txt | AC | 230 ms | 37548 KB |
15.txt | AC | 213 ms | 35960 KB |
16.txt | AC | 223 ms | 37332 KB |
17.txt | AC | 258 ms | 37884 KB |
18.txt | AC | 68 ms | 19028 KB |
19.txt | AC | 73 ms | 18896 KB |
20.txt | AC | 74 ms | 18260 KB |
21.txt | AC | 70 ms | 19284 KB |
22.txt | AC | 68 ms | 19284 KB |
s1.txt | AC | 70 ms | 18772 KB |
s2.txt | AC | 72 ms | 21332 KB |