結果

問題 No.545 ママの大事な二人の子供
ユーザー mbanmban
提出日時 2017-07-14 22:39:45
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,015 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 104,192 KB
実行使用メモリ 23,424 KB
最終ジャッジ日時 2024-04-16 20:36:14
合計ジャッジ時間 5,983 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
23,424 KB
testcase_01 AC 25 ms
17,664 KB
testcase_02 AC 25 ms
17,920 KB
testcase_03 AC 24 ms
17,920 KB
testcase_04 AC 24 ms
17,920 KB
testcase_05 AC 24 ms
17,920 KB
testcase_06 AC 25 ms
17,792 KB
testcase_07 AC 25 ms
17,792 KB
testcase_08 AC 25 ms
17,920 KB
testcase_09 AC 24 ms
17,920 KB
testcase_10 AC 24 ms
17,664 KB
testcase_11 AC 24 ms
17,792 KB
testcase_12 AC 25 ms
17,792 KB
testcase_13 AC 24 ms
17,792 KB
testcase_14 AC 24 ms
17,920 KB
testcase_15 AC 24 ms
17,920 KB
testcase_16 AC 25 ms
17,792 KB
testcase_17 AC 27 ms
17,792 KB
testcase_18 AC 65 ms
17,792 KB
testcase_19 AC 181 ms
18,048 KB
testcase_20 AC 647 ms
17,920 KB
testcase_21 AC 24 ms
17,920 KB
testcase_22 TLE -
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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int N;
    private int[] A, B;
    private void Scan()
    {
        N = int.Parse(Console.ReadLine());
        A = new int[N];
        B = new int[N];
        for (int i = 0; i < N; i++)
        {
            var line = Console.ReadLine().Split(' ');
            A[i] = int.Parse(line[0]);
            B[i] = int.Parse(line[1]);
        }
    }

    private long DFS(long aa,long bb,int n)
    {
        if(n == N)
        {
            return Math.Abs(aa - bb);
        }
        long a = DFS(aa + A[n], bb, n + 1);
        long b = DFS(aa, bb + B[n], n + 1);
        return Math.Min(a , b);
    }

    public void Solve()
    {
        Scan();
        Console.WriteLine(DFS(0, 0, 0));
    }
}
0