提出 #1427006
ソースコード 拡げる
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int K, N, ans = 0;
N = Integer.parseInt(sc.next());
K = Integer.parseInt(sc.next());
int[] l = new int[N];
for(int i = 0; i < N; i++){
l[i] = Integer.parseInt(sc.next());
}
for(int i = 0; i < N; i++){
for(int j = N-1; j > i; j--){
if(l[j] > l[j-1]){
int temp = l[j];
l[j] = l[j-1];
l[j-1] = temp;
}
}
}
for(int i = 0; i < K; i++){
ans += l[i];
}
System.out.println(ans);
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | B - Snake Toy |
| ユーザ | |
| 言語 | Java8 (OpenJDK 1.8.0) |
| 得点 | 200 |
| コード長 | 608 Byte |
| 結果 | AC |
| 実行時間 | 101 ms |
| メモリ | 21972 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 200 / 200 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_example_01.txt, 00_example_02.txt |
| All | 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_example_01.txt | AC | 89 ms | 18644 KiB |
| 00_example_02.txt | AC | 89 ms | 19668 KiB |
| 01.txt | AC | 92 ms | 21972 KiB |
| 02.txt | AC | 92 ms | 21716 KiB |
| 03.txt | AC | 91 ms | 21712 KiB |
| 04.txt | AC | 88 ms | 19796 KiB |
| 05.txt | AC | 90 ms | 19540 KiB |
| 06.txt | AC | 101 ms | 18644 KiB |
| 07.txt | AC | 90 ms | 20820 KiB |
| 08.txt | AC | 88 ms | 20052 KiB |