結果

問題 No.48 ロボットの操縦
ユーザー nanophoto12nanophoto12
提出日時 2014-11-01 15:27:39
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,439 bytes
コンパイル時間 4,157 ms
コンパイル使用メモリ 106,376 KB
実行使用メモリ 22,864 KB
最終ジャッジ日時 2023-08-29 00:09:13
合計ジャッジ時間 6,033 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,812 KB
testcase_01 AC 55 ms
18,776 KB
testcase_02 WA -
testcase_03 AC 54 ms
18,840 KB
testcase_04 AC 55 ms
20,668 KB
testcase_05 AC 54 ms
22,796 KB
testcase_06 AC 55 ms
20,860 KB
testcase_07 AC 55 ms
20,728 KB
testcase_08 AC 56 ms
20,828 KB
testcase_09 AC 56 ms
18,688 KB
testcase_10 AC 58 ms
20,732 KB
testcase_11 AC 57 ms
20,756 KB
testcase_12 AC 56 ms
20,700 KB
testcase_13 AC 55 ms
20,876 KB
testcase_14 AC 58 ms
22,804 KB
testcase_15 AC 56 ms
22,824 KB
testcase_16 AC 55 ms
20,752 KB
testcase_17 AC 55 ms
22,796 KB
testcase_18 AC 55 ms
22,800 KB
testcase_19 AC 56 ms
20,748 KB
testcase_20 AC 56 ms
22,796 KB
testcase_21 AC 54 ms
20,664 KB
testcase_22 AC 55 ms
18,760 KB
testcase_23 AC 55 ms
20,856 KB
testcase_24 AC 56 ms
22,864 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.Globalization;
using System.Linq;

class Program
{
    public static void Main(string[] args)
    {
        int x = int.Parse(Console.ReadLine());
        int y = int.Parse(Console.ReadLine());
        int k = int.Parse(Console.ReadLine());

        int count = 0;

        if (x != 0)
        {
            count++;
        }
        if (y < 0)
        {
            count++;
        }
        if (x != 0)
        {
            count += Math.Abs(x)/k;
            if (Math.Abs(x)%k != 0)
            {
                count++;
            }
        }
        if (y != 0)
        {
            count += Math.Abs(y) / k;
            if (Math.Abs(y) % k != 0)
            {
                count++;
            }
        }
        Console.WriteLine(count.ToString(CultureInfo.InvariantCulture));
    }
}

class Program54
{

    public static void Main54(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        Tuple<int,int>[] valueAndThresholds = new Tuple<int, int>[n];
        for (int i = 0; i < n; i++)
        {
            var line = Console.ReadLine().Split(' ').Select(element => int.Parse(element)).ToArray();
            valueAndThresholds[i] = new Tuple<int, int>(line[0], line[1]);
        }

        Array.Sort(valueAndThresholds, (tuple, tuple1) => (tuple.Item2 + tuple.Item1).CompareTo(tuple1.Item2 + tuple1.Item1));
        var size = valueAndThresholds.Sum(element => element.Item1);

        var dp = new int[size + 1];
        for (int i = 0; i < dp.Length; i++)
        {
            dp[i] = int.MinValue;
        }
        dp[0] = 0;
        for (int index = 0; index < n; index++)
        {
            var current = valueAndThresholds[index];
            var threshold = current.Item2;
            var value = current.Item1;
            for (int j = 0; j < threshold; j++)
            {
                if (j + value < size + 1)
                {
                    if (dp[j] != int.MinValue)
                    {
                        dp[j + value] = Math.Max(dp[j + value], dp[j] + value);
                    }                    
                }
            }
        }
        int max = 0;
        for (int i = 0; i < dp.Length; i++)
        {
            max = Math.Max(max, dp[i]);
        }
        Console.WriteLine(max.ToString(CultureInfo.InvariantCulture));
    }
}
0