Submission #1001475
Source Code Expand
using System; using System.Text; using System.Collections.Generic; class Solve{ int N; long[] A; public Solve(){} StringBuilder sb; public static int Main(){ new Solve().Run(); return 0; } void Run(){ sb = new StringBuilder(); Read(); Calc(); Console.Write(sb.ToString()); } void Calc(){ int[] chosen = new int[N]; long[] sum = new long[N]; int p = 0; long t = 0; for(int i=2;i<N;i++){ if(A[i] >= t){ while(p > 0){ t += sum[p-1]; t += A[chosen[p-1]]; if(A[i] < t){ t -= sum[p-1]; t -= A[chosen[p-1]]; break; } p--; } sum[p] = t; chosen[p] = i; p++; t = 0; } else{ t += A[i]; } } long count = 0; count += A[0]-A[1]; int s = 1; for(int i=0;i<p;i++){ count += s*A[chosen[i]]; count -= s*sum[i]; s *= -1; } sb.Append(count+"\n"); } void Read(){ N = int.Parse(Console.ReadLine()); A = new long[N]; string[] str = Console.ReadLine().Split(' '); for(int i=0;i<N-1;i++){ A[i] = int.Parse(str[i]); } Console.ReadLine(); A[N-1] = Int64.Parse(Console.ReadLine()); } }
Submission Info
Submission Time | |
---|---|
Task | H - Tokaido |
User | leign |
Language | C# (Mono 4.6.2.0) |
Score | 0 |
Code Size | 1653 Byte |
Status | WA |
Exec Time | 89 ms |
Memory | 18136 KB |
Judge Result
Set Name | sample | dataset1 | dataset2 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | 0 / 900 | ||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt |
dataset1 | sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt |
dataset2 | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 88 ms | 18136 KB |
01-02.txt | AC | 20 ms | 2648 KB |
01-03.txt | WA | 21 ms | 2904 KB |
01-04.txt | WA | 52 ms | 9944 KB |
01-05.txt | WA | 87 ms | 18008 KB |
01-06.txt | WA | 87 ms | 18008 KB |
01-07.txt | WA | 39 ms | 7256 KB |
01-08.txt | WA | 89 ms | 17880 KB |
01-09.txt | WA | 89 ms | 18004 KB |
01-10.txt | AC | 20 ms | 2648 KB |
01-11.txt | AC | 32 ms | 5336 KB |
01-12.txt | AC | 84 ms | 17240 KB |
01-13.txt | AC | 87 ms | 17496 KB |
01-14.txt | WA | 86 ms | 17368 KB |
01-15.txt | WA | 87 ms | 17496 KB |
01-16.txt | AC | 83 ms | 17240 KB |
01-17.txt | AC | 83 ms | 17240 KB |
01-18.txt | AC | 84 ms | 17240 KB |
01-19.txt | AC | 83 ms | 17240 KB |
02-01.txt | WA | 32 ms | 5464 KB |
02-02.txt | WA | 88 ms | 18008 KB |
02-03.txt | WA | 87 ms | 18008 KB |
02-04.txt | WA | 86 ms | 18008 KB |
02-05.txt | WA | 21 ms | 2776 KB |
02-06.txt | WA | 88 ms | 18008 KB |
02-07.txt | WA | 88 ms | 17880 KB |
02-08.txt | WA | 20 ms | 2648 KB |
02-09.txt | WA | 21 ms | 2776 KB |
02-10.txt | WA | 51 ms | 9432 KB |
02-11.txt | WA | 87 ms | 17496 KB |
02-12.txt | WA | 86 ms | 17240 KB |
02-13.txt | WA | 87 ms | 17496 KB |
02-14.txt | WA | 84 ms | 17240 KB |
02-15.txt | WA | 83 ms | 17240 KB |
02-16.txt | WA | 83 ms | 17236 KB |
sample-01.txt | AC | 20 ms | 2648 KB |
sample-02.txt | WA | 20 ms | 2648 KB |