Submission #5066355
Source Code Expand
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using BitArray = System.Collections.BitArray; using BigInteger = System.Numerics.BigInteger; namespace AtCoderProject { class Program { static void Main() { Console.WriteLine(new Program().Calc()); } public object Calc() { var N = ReadLineInt32(); var a = ReadLineSplitInt32(); var sum = a.Sum(); var dp = new bool[sum]; dp[0] = true; foreach (var item in a) { for (int i = dp.Length - 1; i >= 0; i--) { if (dp[i]) { var index = i + item; if (index < sum) dp[index] = true; } } } return dp.Count(b => b) + 1; } #if DEBUG #pragma warning disable IDE0051 // 使用されていないプライベート メンバーを削除する #pragma warning disable IDE1006 // 命名スタイル static string _ReadLineImpl() => queue.Dequeue(); #pragma warning restore IDE1006 // 命名スタイル static readonly Queue<string> queue; static Program() { string input = @" 3 2 3 5 "; queue = new Queue<string>(); foreach (var line in input.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)) queue.Enqueue(line); } #else private static string _ReadLineImpl() => Console.ReadLine(); #endif static string ReadLine() => _ReadLineImpl(); static int ReadLineInt32() => int.Parse(ReadLine()); static long ReadLineInt64() => long.Parse(ReadLine()); static ulong ReadLineUInt64() => ulong.Parse(ReadLine()); static double ReadLineDouble() => double.Parse(ReadLine()); static string[] ReadLineSplit() => ReadLine().Split().ToArray(); static int[] ReadLineSplitInt32() => ReadLine().Split().Select(s => int.Parse(s)).ToArray(); static long[] ReadLineSplitInt64() => ReadLine().Split().Select(s => long.Parse(s)).ToArray(); static ulong[] ReadLineSplitUInt64() => ReadLine().Split().Select(s => ulong.Parse(s)).ToArray(); static double[] ReadLineSplitDouble() => ReadLine().Split().Select(s => double.Parse(s)).ToArray(); static IEnumerable<string> RepeatReadLines(int count) { for (int i = 0; i < count; i++) yield return ReadLine(); } static IEnumerable<int> RepeatReadLinesInt32(int count) { for (int i = 0; i < count; i++) yield return ReadLineInt32(); } static IEnumerable<string[]> RepeatReadLinesSplit(int count) { for (int i = 0; i < count; i++) yield return ReadLineSplit(); } } static class BitArrayUtils { static BitArray ToBitArray(this long l) { return new BitArray(BitConverter.GetBytes(l)); } static long ToInt64(this BitArray bitArray) { var array = new byte[8]; bitArray.CopyTo(array, 0); return BitConverter.ToInt64(array, 0); } static BitArray ToBitArray(this ulong l) { return new BitArray(BitConverter.GetBytes(l)); } static ulong ToUInt64(this BitArray bitArray) { var array = new byte[8]; bitArray.CopyTo(array, 0); return BitConverter.ToUInt64(array, 0); } } }
Submission Info
Submission Time | |
---|---|
Task | A - コンテスト |
User | kzrnm |
Language | C# (Mono 4.6.2.0) |
Score | 2 |
Code Size | 3820 Byte |
Status | AC |
Exec Time | 25 ms |
Memory | 11348 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 2 / 2 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00, 01, 02, 90, 91 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00 | AC | 25 ms | 11348 KB |
01 | AC | 24 ms | 9300 KB |
02 | AC | 25 ms | 11348 KB |
90 | AC | 23 ms | 9300 KB |
91 | AC | 23 ms | 11348 KB |