結果

問題 No.91 赤、緑、青の石
ユーザー mbanmban
提出日時 2017-02-18 02:57:13
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 2,624 ms / 5,000 ms
コード長 2,416 bytes
コンパイル時間 2,848 ms
コンパイル使用メモリ 107,000 KB
実行使用メモリ 30,032 KB
最終ジャッジ日時 2023-09-06 12:26:58
合計ジャッジ時間 31,206 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,842 ms
26,032 KB
testcase_01 AC 1,218 ms
28,092 KB
testcase_02 AC 777 ms
25,920 KB
testcase_03 AC 1,296 ms
26,104 KB
testcase_04 AC 660 ms
26,116 KB
testcase_05 AC 1,667 ms
30,032 KB
testcase_06 AC 433 ms
28,056 KB
testcase_07 AC 63 ms
19,788 KB
testcase_08 AC 63 ms
23,928 KB
testcase_09 AC 63 ms
21,832 KB
testcase_10 AC 63 ms
22,028 KB
testcase_11 AC 529 ms
25,928 KB
testcase_12 AC 1,473 ms
26,024 KB
testcase_13 AC 1,600 ms
25,960 KB
testcase_14 AC 1,077 ms
27,960 KB
testcase_15 AC 1,742 ms
28,148 KB
testcase_16 AC 64 ms
23,896 KB
testcase_17 AC 64 ms
21,992 KB
testcase_18 AC 64 ms
21,836 KB
testcase_19 AC 65 ms
21,980 KB
testcase_20 AC 65 ms
24,072 KB
testcase_21 AC 64 ms
22,060 KB
testcase_22 AC 64 ms
21,896 KB
testcase_23 AC 65 ms
23,940 KB
testcase_24 AC 64 ms
21,840 KB
testcase_25 AC 2,624 ms
28,076 KB
testcase_26 AC 2,313 ms
26,032 KB
testcase_27 AC 59 ms
21,900 KB
testcase_28 AC 213 ms
28,180 KB
testcase_29 AC 386 ms
28,076 KB
testcase_30 AC 1,886 ms
25,968 KB
testcase_31 AC 2,408 ms
28,016 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;
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(string[] args)
    {
        new Magatro().Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;

    private string[] S;
    private int Index;
    private const char Separator = ' ';

    public Scanner(Stream source)
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(source);
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public decimal NextDecimal()
    {
        return decimal.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[] LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }
    public bool EndOfStream
    {
        get { return Sr.EndOfStream; }
    }
}

public class Magatro
{
    private Scanner Cin;

    private int[] Arr;
    private void Scan()
    {
        Cin = new Scanner(Console.OpenStandardInput());
        Arr = Cin.IntArray();
    }

    public void Solve()
    {
        Scan();
        Array.Sort(Arr);
        int count = 0;
        while (true)
        {
            
            if (Arr.Count(i => i <= 0) > 0)
            {
                Array.Sort(Arr);
                Arr[2] -= 2;
                Arr[0]++;
                if (Arr.Min() < 0) break;
            }
            else
            {
                int plus = Arr.Min();
                count += plus;
                Arr = Arr.Select(i => i - plus).ToArray();
            }
        }
        Console.WriteLine(count);
    }
}
0