結果

問題 No.710 チーム戦
ユーザー Tomohiko HasegawaTomohiko Hasegawa
提出日時 2019-03-30 15:37:31
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 118 ms / 3,000 ms
コード長 2,163 bytes
コンパイル時間 1,056 ms
コンパイル使用メモリ 113,164 KB
実行使用メモリ 47,972 KB
最終ジャッジ日時 2024-04-27 14:24:00
合計ジャッジ時間 4,920 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,952 KB
testcase_01 AC 30 ms
25,756 KB
testcase_02 AC 107 ms
41,576 KB
testcase_03 AC 107 ms
43,368 KB
testcase_04 AC 110 ms
43,628 KB
testcase_05 AC 108 ms
43,748 KB
testcase_06 AC 109 ms
45,920 KB
testcase_07 AC 111 ms
47,972 KB
testcase_08 AC 110 ms
43,628 KB
testcase_09 AC 110 ms
45,796 KB
testcase_10 AC 107 ms
45,660 KB
testcase_11 AC 107 ms
45,544 KB
testcase_12 AC 110 ms
43,492 KB
testcase_13 AC 109 ms
45,680 KB
testcase_14 AC 110 ms
43,496 KB
testcase_15 AC 107 ms
43,500 KB
testcase_16 AC 110 ms
45,544 KB
testcase_17 AC 107 ms
43,496 KB
testcase_18 AC 109 ms
45,548 KB
testcase_19 AC 109 ms
43,500 KB
testcase_20 AC 109 ms
43,752 KB
testcase_21 AC 112 ms
41,448 KB
testcase_22 AC 93 ms
43,752 KB
testcase_23 AC 93 ms
45,688 KB
testcase_24 AC 118 ms
41,576 KB
testcase_25 AC 26 ms
22,068 KB
testcase_26 AC 27 ms
23,888 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 static System.Console;
using static System.Math;

namespace AtTest.DP
{
    class yuki710
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[][] abs = new int[n][];
            for(int i = 0; i < n; i++)
            {
                abs[i] = ReadInts();
            }
            int length = 100000 + 1000;
            int inf = int.MaxValue / 4;
            int[] dp = new int[length];
            for (int i = 0; i < length; i++) dp[i] = inf;
            dp[0] = 0;
            for (int i = 0; i < n; i++)
            {
                int[] next = new int[length];
                for (int j = 0; j < length; j++) next[j] = inf;
                for (int j = 0; j < length; j++)
                {
                    if (dp[j] == inf) continue;

                    next[j] = Min(next[j], dp[j] + abs[i][1]);
                    int nextIndex = j + abs[i][0];
                    if (nextIndex < length)
                    {
                        next[nextIndex] = Min(next[nextIndex], dp[j]);
                    }
                }
                dp = next;
            }
            int min = int.MaxValue;
            for(int i = 0; i < length; i++)
            {
                min = Min(min, Max(i, dp[i]));
                //if (i <= 10) WriteLine(dp[i]);
            }
            WriteLine(min);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}
0