結果

問題 No.110 しましまピラミッド
ユーザー mbanmban
提出日時 2017-01-13 10:22:09
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 62 ms / 5,000 ms
コード長 3,885 bytes
コンパイル時間 3,913 ms
コンパイル使用メモリ 105,824 KB
実行使用メモリ 22,880 KB
最終ジャッジ日時 2023-08-30 03:57:04
合計ジャッジ時間 5,348 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
20,744 KB
testcase_01 AC 59 ms
20,608 KB
testcase_02 AC 59 ms
20,776 KB
testcase_03 AC 59 ms
20,844 KB
testcase_04 AC 59 ms
20,728 KB
testcase_05 AC 59 ms
20,928 KB
testcase_06 AC 59 ms
20,804 KB
testcase_07 AC 60 ms
20,740 KB
testcase_08 AC 59 ms
20,848 KB
testcase_09 AC 59 ms
20,736 KB
testcase_10 AC 59 ms
22,732 KB
testcase_11 AC 60 ms
20,792 KB
testcase_12 AC 59 ms
20,624 KB
testcase_13 AC 60 ms
22,776 KB
testcase_14 AC 60 ms
22,728 KB
testcase_15 AC 59 ms
20,676 KB
testcase_16 AC 62 ms
22,880 KB
testcase_17 AC 59 ms
18,872 KB
testcase_18 AC 58 ms
20,664 KB
testcase_19 AC 59 ms
20,756 KB
testcase_20 AC 59 ms
20,720 KB
testcase_21 AC 60 ms
20,784 KB
testcase_22 AC 59 ms
22,780 KB
testcase_23 AC 59 ms
22,784 KB
testcase_24 AC 60 ms
20,920 KB
testcase_25 AC 58 ms
20,732 KB
testcase_26 AC 59 ms
20,608 KB
testcase_27 AC 59 ms
20,840 KB
testcase_28 AC 57 ms
20,740 KB
testcase_29 AC 59 ms
22,804 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 private Magatro M = new Magatro();
    static private void Main(string[]args)
    {
        M.Scan();
        M.Solve();
    }
}

public class Scanner
{
    private string[] S;
    private int Index;
    private char Separator;

    public Scanner(char separator = ' ')
    {
        Index = 0;
        Separator = separator;
        S = new string[0];
    }

    private string[] Line()
    {
        return Console.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 class Magatro
{
    private int Nw, Nb;
    private int[] W, B;

    public void Scan()
    {
        Scanner sc = new Scanner();
        Nw = sc.NextInt();
        W = new int[Nw];
        for(int i = 0; i < Nw; i++)
        {
            W[i] = sc.NextInt();
        }
        Nb = sc.NextInt();
        B = new int[Nb];
        for(int i = 0; i < Nb; i++)
        {
            B[i] = sc.NextInt();
        }
    }

    public void Solve()
    {
        int ans;
        int black, white;
        Array.Sort(W,(a,b)=>-a.CompareTo(b));
        Array.Sort(B,(a,b)=>-a.CompareTo(b));
        int type = 0;
        white = 1;
        int block = W[0];
        bool flag;
        while (true)
        {
            if (type == 0)
            {
                type = 1;
                flag = false;
                for (int i = 0; i < Nb; i++)
                {
                    if (block > B[i])
                    {
                        block = B[i];
                        white++;
                        flag = true;
                        break;
                    }
                }
                if (flag) continue;
                break;
            }
            else
            {
                type = 0;
                flag = false;
                for (int i = 0; i < Nw; i++)
                {
                    if (block > W[i])
                    {
                        block = W[i];
                        white++;
                        flag = true;
                        break;
                    }
                }
                if (flag) continue;
                break;
            }
        }
        black = 1;
        type = 1;
        block = B[0];
        while (true)
        {
            if (type == 0)
            {
                type = 1;
                flag = false;
                for (int i = 0; i < Nb; i++)
                {
                    if (block > B[i])
                    {
                        block = B[i];
                        black++;
                        flag = true;
                        break;
                    }
                }
                if (flag) continue;
                break;
            }
            else
            {
                type = 0;
                flag = false;
                for (int i = 0; i < Nw; i++)
                {
                    if (block > W[i])
                    {
                        block = W[i];
                        black++;
                        flag = true;
                        break;
                    }
                }
                if (flag) continue;
                break;
            }
        }
        Console.WriteLine(Math.Max(black, white));
    }

}
0