Submission #1001998
Source Code Expand
using System; using System.Text; using System.Collections.Generic; class Solve{ int N; int[] 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(){ Que Q; int sum = 0; for(int i=2;i<N-1;i++){ sum += A[i]; } { int[] d = new int[sum]; for(int i=0;i<sum;i++){ d[i] = i; } Q = new Que(d); } for(int i=2;i<N-1;i++){ Console.WriteLine(i); if(A[i]*2 >= sum){ int[] d = new int[sum]; for(int j=0;j<A[i];j++){ d[j] = Q.Get(A[i]-j); } for(int j=A[i];j<sum;j++){ d[j] = Q.Get(j-A[i]); } Q = new Que(d); } else{ for(int j=0;j<A[i];j++){ Q.Put(Q.Get(2*j+1)); } } } int M = int.Parse(Console.ReadLine()); for(int i=0;i<M;i++){ long j = Int64.Parse(Console.ReadLine()); if(j >= sum){ long ans = j - sum + A[0] - A[1]; sb.Append(ans+"\n"); } else{ long ans = Q.Get((int)(j)) + A[0] - A[1]; sb.Append(ans+"\n"); } } } void Read(){ N = int.Parse(Console.ReadLine()); A = new int[N-1]; string[] str = Console.ReadLine().Split(' '); for(int i=0;i<N-1;i++){ A[i] = int.Parse(str[i]); } } } class Que{ public int[] array; int pointer; int length; public Que(int[] a){ array = a; pointer = 0; length = a.Length; } public Que(int n){ array = new int[n]; pointer = n; length = n; } public void Put(int a){ if(pointer == 0){ pointer = length-1; } else{ pointer--; } array[pointer] = a; } public int Get(int n){ if(pointer + n >= length){ return array[pointer + n - length]; } else{ return array[pointer + n]; } } }
Submission Info
Submission Time | |
---|---|
Task | H - Tokaido |
User | leign |
Language | C# (Mono 4.6.2.0) |
Score | 0 |
Code Size | 2529 Byte |
Status | WA |
Exec Time | 2104 ms |
Memory | 26664 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 | TLE | 2104 ms | 21456 KB |
01-02.txt | AC | 21 ms | 2776 KB |
01-03.txt | WA | 56 ms | 6872 KB |
01-04.txt | WA | 1049 ms | 16984 KB |
01-05.txt | TLE | 2104 ms | 21456 KB |
01-06.txt | TLE | 2104 ms | 21456 KB |
01-07.txt | WA | 648 ms | 12376 KB |
01-08.txt | TLE | 2104 ms | 21584 KB |
01-09.txt | TLE | 2104 ms | 21712 KB |
01-10.txt | WA | 34 ms | 6616 KB |
01-11.txt | WA | 446 ms | 13912 KB |
01-12.txt | TLE | 2060 ms | 23896 KB |
01-13.txt | TLE | 2104 ms | 24148 KB |
01-14.txt | TLE | 2104 ms | 25168 KB |
01-15.txt | TLE | 2104 ms | 25168 KB |
01-16.txt | TLE | 2104 ms | 25296 KB |
01-17.txt | TLE | 2104 ms | 17464 KB |
01-18.txt | TLE | 2104 ms | 17464 KB |
01-19.txt | TLE | 2104 ms | 17464 KB |
02-01.txt | WA | 407 ms | 14296 KB |
02-02.txt | TLE | 2104 ms | 21456 KB |
02-03.txt | TLE | 2104 ms | 21456 KB |
02-04.txt | TLE | 2104 ms | 21456 KB |
02-05.txt | WA | 196 ms | 14768 KB |
02-06.txt | TLE | 2104 ms | 21712 KB |
02-07.txt | TLE | 2104 ms | 21712 KB |
02-08.txt | WA | 219 ms | 21424 KB |
02-09.txt | WA | 199 ms | 17200 KB |
02-10.txt | WA | 1260 ms | 26664 KB |
02-11.txt | TLE | 2104 ms | 24024 KB |
02-12.txt | TLE | 2104 ms | 24024 KB |
02-13.txt | TLE | 2104 ms | 24024 KB |
02-14.txt | TLE | 2104 ms | 24024 KB |
02-15.txt | TLE | 2104 ms | 17464 KB |
02-16.txt | TLE | 2104 ms | 17464 KB |
sample-01.txt | WA | 21 ms | 2776 KB |
sample-02.txt | WA | 20 ms | 2776 KB |