提出 #778400
ソースコード 拡げる
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
List<Integer> array = new ArrayList<Integer>();
for(int i = 0; i < n; i++) {
array.add(sc.nextInt());
}
System.out.println(bp(n, array));
}
private static int bp(int n, List<Integer> array) {
int ans = 0;
if(n == 1) {
ans = 0;
} else if(n == 2) {
ans = Math.abs(array.get(1) - array.get(0));
} else {
int tmp1, tmp2;
tmp1 = Math.abs(array.get(n - 1) - array.get(n - 3)) + bp(n - 2, array); //最後が2個飛び
tmp2 = Math.abs(array.get(n - 1) - array.get(n - 2)) + bp(n - 1, array); //最後が隣
ans = Math.min(tmp1, tmp2);
}
return ans;
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | A - 赤赤赤赤青 |
| ユーザ | eskinesics |
| 言語 | Java7 (OpenJDK 1.7.0) |
| 得点 | 0 |
| コード長 | 833 Byte |
| 結果 | RE |
| 実行時間 | 224 ms |
| メモリ | 8788 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 100 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | sample_01.txt, sample_02.txt, sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| sample_01.txt | RE | 215 ms | 8660 KiB |
| sample_02.txt | RE | 211 ms | 8788 KiB |
| sample_03.txt | RE | 215 ms | 8660 KiB |
| subtask1_01.txt | AC | 214 ms | 8660 KiB |
| subtask1_02.txt | RE | 215 ms | 8784 KiB |
| subtask1_03.txt | RE | 211 ms | 8660 KiB |
| subtask1_04.txt | RE | 215 ms | 8660 KiB |
| subtask1_05.txt | RE | 219 ms | 8788 KiB |
| subtask1_06.txt | RE | 211 ms | 8788 KiB |
| subtask1_07.txt | RE | 222 ms | 8788 KiB |
| subtask1_08.txt | RE | 219 ms | 8660 KiB |
| subtask1_09.txt | RE | 222 ms | 8788 KiB |
| subtask1_10.txt | RE | 224 ms | 8788 KiB |