提出 #1428073
ソースコード 拡げる
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N;
long ans = 0;
N = Integer.parseInt(sc.next());
int[] a = new int[N];
for(int i = 0; i < N; i++){
a[i] = Integer.parseInt(sc.next());
}
long x = 0;
long y = 0;
x = a[0];
for(int i = 1; i < N; i++){
y += a[i];
}
ans = Math.abs(x-y);
for(int i = 1; i < N-1; i++){
x += a[i];
y -= a[i];
ans = Math.min(ans, Math.abs(x-y));
}
System.out.println(ans);
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Splitting Pile |
| ユーザ | |
| 言語 | Java8 (OpenJDK 1.8.0) |
| 得点 | 300 |
| コード長 | 580 Byte |
| 結果 | AC |
| 実行時間 | 484 ms |
| メモリ | 63480 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_example_01.txt | AC | 99 ms | 23124 KiB |
| 00_example_02.txt | AC | 94 ms | 18900 KiB |
| 01.txt | AC | 367 ms | 47648 KiB |
| 02.txt | AC | 231 ms | 40480 KiB |
| 03.txt | AC | 212 ms | 35500 KiB |
| 04.txt | AC | 375 ms | 44208 KiB |
| 05.txt | AC | 228 ms | 36472 KiB |
| 06.txt | AC | 447 ms | 48756 KiB |
| 07.txt | AC | 447 ms | 48164 KiB |
| 08.txt | AC | 416 ms | 46904 KiB |
| 09.txt | AC | 484 ms | 50460 KiB |
| 10.txt | AC | 480 ms | 60024 KiB |
| 11.txt | AC | 96 ms | 23124 KiB |
| 12.txt | AC | 132 ms | 21460 KiB |
| 13.txt | AC | 412 ms | 63480 KiB |
| 14.txt | AC | 94 ms | 21716 KiB |