Contest Duration: - (local time) (120 minutes) Back to Home

Submission #123117

Source Code Expand

Copy
```import java.util.ArrayList;
import java.util.Scanner;

public class Main {

Scanner sc = new Scanner(System.in);
public void run() {
int n = sc.nextInt();
int k = sc.nextInt();
calc(n, k);

}
public void calc(int n, int k){
int[] rates = new int[n];
for(int i = 0; i < n; i++){
rates[i] = sc.nextInt();
}

rates = mergesort(rates);
double ans = 0;

//System.out.printf("%3s%n", Integer.toBinaryString(nowfrag));
for(int i = k-1; i >= 0; i--){
ans = (ans + rates[i])/2;
}
System.out.printf("%-8f", ans);
}

public int[] mergesort(int[] a){
if(a.length == 1) return a;
else{
int l1 = a.length / 2;
int l2 = a.length - l1;

int[] a1 = new int[l1];
int[] a2 = new int[l2];
for(int i = 0; i < l1; i++) a1[i] = a[i];
for(int i = 0; i < l2; i++) a2[i] = a[i+l1];
a1 = mergesort(a1);
a2 = mergesort(a2);

int[] ans = merge(a1, a2);
return ans;
}
}
public int[] merge(int[] a1, int[]a2){
int i = 0;
int j = 0;
int[] ans = new int[a1.length + a2.length];
int c = 0;
while(i < a1.length || j < a2.length){
if(j >= a2.length || (i < a1.length && a1[i] > a2[j]) ){
ans[c] = a1[i];
i = i + 1;
c= c + 1;
}
else{
ans[c] = a2[j];
j = j + 1;
c = c + 1;
}
}
return ans;
}

public static void main(String[] args) {
new Main().run();
}
}```

Submission Info

Submission Time 2013-12-12 22:57:03+0900 C - AtCoderプログラミング講座 wapiko Java (OpenJDK 1.7.0) 100 1423 Byte AC 542 ms 23988 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
 AC × 34
Set Name Test Cases
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 492 ms 23352 KB
00_sample_02.txt AC 477 ms 23344 KB
00_sample_03.txt AC 542 ms 23340 KB
00_sample_04.txt AC 482 ms 23472 KB
test_01.txt AC 483 ms 23320 KB
test_02.txt AC 496 ms 23728 KB
test_03.txt AC 491 ms 23864 KB
test_04.txt AC 492 ms 23596 KB
test_05.txt AC 495 ms 23860 KB
test_06.txt AC 500 ms 23608 KB
test_07.txt AC 500 ms 23856 KB
test_08.txt AC 500 ms 23728 KB
test_09.txt AC 499 ms 23988 KB
test_10.txt AC 504 ms 23860 KB
test_11.txt AC 487 ms 23480 KB
test_12.txt AC 500 ms 23728 KB
test_13.txt AC 493 ms 23732 KB
test_14.txt AC 494 ms 23860 KB
test_15.txt AC 508 ms 23608 KB
test_16.txt AC 516 ms 23348 KB
test_17.txt AC 492 ms 23732 KB
test_18.txt AC 508 ms 23860 KB
test_19.txt AC 506 ms 23732 KB
test_20.txt AC 499 ms 23344 KB
test_21.txt AC 499 ms 23728 KB
test_22.txt AC 504 ms 23856 KB
test_23.txt AC 495 ms 23344 KB
test_24.txt AC 490 ms 23468 KB
test_25.txt AC 498 ms 23728 KB
test_26.txt AC 519 ms 23860 KB
test_27.txt AC 530 ms 23348 KB
test_28.txt AC 498 ms 23396 KB
test_29.txt AC 499 ms 23860 KB
test_30.txt AC 497 ms 23860 KB