Submission #1856972
Source Code Expand
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String args[]){ Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int card[] = new int[n]; int total = 0; for (int i = 0;i < n;++i) { card[i] = scanner.nextInt(); total += card[i]; } long sub = card[0]; double subd = Long.MAX_VALUE; for (int i = 1;i < n;++i){ double i2 = Math.abs(total / 2D - sub); if(i2 < subd){ subd = i2; } if(i >= n - 2){ break; } sub += card[i]; } System.out.println((int)(subd * 2)); } }
Submission Info
Submission Time | |
---|---|
Task | C - Splitting Pile |
User | reik |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 786 Byte |
Status | WA |
Exec Time | 572 ms |
Memory | 64916 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 91 ms | 18772 KB |
00_example_02.txt | AC | 93 ms | 21716 KB |
01.txt | WA | 417 ms | 48980 KB |
02.txt | WA | 324 ms | 40120 KB |
03.txt | WA | 276 ms | 41520 KB |
04.txt | WA | 461 ms | 59524 KB |
05.txt | WA | 273 ms | 42244 KB |
06.txt | WA | 572 ms | 63496 KB |
07.txt | WA | 554 ms | 64916 KB |
08.txt | WA | 542 ms | 64684 KB |
09.txt | WA | 544 ms | 63924 KB |
10.txt | WA | 549 ms | 63080 KB |
11.txt | AC | 96 ms | 21716 KB |
12.txt | AC | 142 ms | 21204 KB |
13.txt | AC | 503 ms | 64572 KB |
14.txt | AC | 95 ms | 21588 KB |