結果

問題 No.791 うし数列
ユーザー funakoshifunakoshi
提出日時 2019-07-02 10:47:27
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 1,260 bytes
コンパイル時間 4,446 ms
コンパイル使用メモリ 103,296 KB
実行使用メモリ 22,732 KB
最終ジャッジ日時 2023-09-27 02:02:04
合計ジャッジ時間 6,633 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
20,488 KB
testcase_01 AC 53 ms
18,508 KB
testcase_02 AC 55 ms
22,492 KB
testcase_03 AC 54 ms
20,452 KB
testcase_04 AC 53 ms
22,500 KB
testcase_05 AC 56 ms
20,600 KB
testcase_06 AC 55 ms
22,504 KB
testcase_07 AC 52 ms
20,620 KB
testcase_08 AC 52 ms
20,628 KB
testcase_09 AC 53 ms
22,584 KB
testcase_10 AC 52 ms
22,508 KB
testcase_11 AC 53 ms
20,600 KB
testcase_12 AC 53 ms
20,492 KB
testcase_13 AC 53 ms
20,428 KB
testcase_14 AC 53 ms
22,732 KB
testcase_15 AC 53 ms
22,552 KB
testcase_16 AC 52 ms
20,508 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 System.Threading.Tasks;

namespace yukicoderTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int cnt = 0;
            int max = -1;
            bool flg = true;
            for (int i = 0; i < str.Length - 1; i++)
            {
                if (str.Substring(i, 1) == 1.ToString())
                {
                    for (int j = i + 1; j < str.Length; j++)
                    {
                        if (str.Substring(j, 1) == 3.ToString())
                        {
                            cnt++;
                        }
                        else
                        {
                            flg = false;
                            break;
                        }
                        if(cnt>max)
                        {
                            max = cnt;
                        }
                    }

                }
            }
            if (flg != false)
            {
                Console.WriteLine(max);
            }
            else
            {
                Console.WriteLine("-1");
            }
        }
    }
}
0