結果

問題 No.545 ママの大事な二人の子供
ユーザー neko_the_shadowneko_the_shadow
提出日時 2018-06-14 23:51:35
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,008 bytes
コンパイル時間 3,006 ms
コンパイル使用メモリ 104,728 KB
実行使用メモリ 242,712 KB
最終ジャッジ日時 2023-09-13 04:25:14
合計ジャッジ時間 12,261 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
25,004 KB
testcase_01 AC 72 ms
23,012 KB
testcase_02 AC 73 ms
20,828 KB
testcase_03 AC 72 ms
24,992 KB
testcase_04 AC 73 ms
23,044 KB
testcase_05 AC 72 ms
23,088 KB
testcase_06 AC 72 ms
22,944 KB
testcase_07 AC 74 ms
23,048 KB
testcase_08 AC 73 ms
22,948 KB
testcase_09 AC 72 ms
22,888 KB
testcase_10 AC 72 ms
22,952 KB
testcase_11 AC 73 ms
25,036 KB
testcase_12 AC 71 ms
20,936 KB
testcase_13 AC 75 ms
23,812 KB
testcase_14 AC 78 ms
27,248 KB
testcase_15 AC 72 ms
25,072 KB
testcase_16 AC 85 ms
29,820 KB
testcase_17 AC 131 ms
41,620 KB
testcase_18 AC 1,618 ms
242,712 KB
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _545
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var inputs = Enumerable.Range(0, n).Select(_ =>
            {
                var line = Console.ReadLine().Split().Select(long.Parse).ToList();
                return Tuple.Create(line[0], line[1]);
            }).ToList();

            var diffs = new HashSet<long>() { 0 };
            foreach (var input in inputs)
            {
                var nexts = new HashSet<long>();
                foreach (var diff in diffs)
                {
                    nexts.Add(diff + input.Item1);
                    nexts.Add(diff - input.Item2);
                }
                diffs = nexts;
            }

            var answer = Math.Abs(diffs.Min(diff => Math.Abs(diff)));
            Console.WriteLine(answer);
        }
    }
}
0