Submission #3271212
Source Code Expand
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] origin = new int[n]; int[] sorted = new int[n]; for(int i = 0; i < n; i++) { int num = sc.nextInt(); origin[i] = num; sorted[i] = num; } Arrays.sort(sorted); int medianIndex1 = sorted.length / 2 - 1; int median1 = sorted[medianIndex1]; int medianIndex2 = sorted.length / 2; int median2 = sorted[medianIndex2]; for(int i = 0; i < n; i++) { if(origin[i] <= median1) { System.out.println(median2); } else { System.out.println(median1); } } } }
Submission Info
Submission Time | |
---|---|
Task | C - Many Medians |
User | usagi4430 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 829 Byte |
Status | AC |
Exec Time | 1608 ms |
Memory | 93496 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 11.txt, 12.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
1.txt | AC | 105 ms | 21332 KB |
10.txt | AC | 1506 ms | 76964 KB |
11.txt | AC | 1438 ms | 93496 KB |
12.txt | AC | 1203 ms | 63484 KB |
2.txt | AC | 980 ms | 62612 KB |
3.txt | AC | 1466 ms | 82728 KB |
4.txt | AC | 1446 ms | 80120 KB |
5.txt | AC | 1502 ms | 88448 KB |
6.txt | AC | 1467 ms | 73560 KB |
7.txt | AC | 1608 ms | 90864 KB |
8.txt | AC | 1530 ms | 82348 KB |
9.txt | AC | 1514 ms | 91904 KB |
sample1.txt | AC | 95 ms | 21840 KB |
sample2.txt | AC | 94 ms | 21076 KB |
sample3.txt | AC | 93 ms | 21716 KB |