結果

問題 No.607 開通777年記念
ユーザー mbanmban
提出日時 2018-01-15 23:09:07
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,310 bytes
コンパイル時間 2,310 ms
コンパイル使用メモリ 105,872 KB
実行使用メモリ 54,996 KB
最終ジャッジ日時 2023-08-25 17:59:12
合計ジャッジ時間 4,382 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,772 KB
testcase_01 AC 56 ms
18,772 KB
testcase_02 AC 58 ms
20,828 KB
testcase_03 AC 58 ms
20,720 KB
testcase_04 AC 58 ms
20,892 KB
testcase_05 AC 58 ms
20,720 KB
testcase_06 AC 58 ms
20,872 KB
testcase_07 AC 111 ms
26,460 KB
testcase_08 AC 57 ms
22,788 KB
testcase_09 AC 61 ms
20,776 KB
testcase_10 AC 60 ms
20,748 KB
testcase_11 AC 346 ms
54,996 KB
testcase_12 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Diagnostics;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    private long NextLong()
    {
        return long.Parse(Next());
    }
}

class Program
{
    private int N, M;
    private long[,] A;
    private long[] Train;
    private void Scan()
    {
        var line = Console.ReadLine().Split(' ');
        N = int.Parse(line[0]);
        M = int.Parse(line[1]);
        A = new long[M, N];
        for (int i = 0; i < M; i++)
        {
            line = Console.ReadLine().Split(' ');
            for (int j = 0; j < N; j++)
            {
                A[i, j] = long.Parse(line[j]);
            }
        }
    }

    public void Solve()
    {
        Scan();
        Train = new long[N];
        for (int i = 0; i < M; i++)
        {
            for (int j = 0; j < N; j++)
            {
                Train[j] += A[i, j];
            }
            if (C())
            {
                Console.WriteLine("YES");
                return;
            }
        }
        Console.WriteLine("NO");
    }

    private bool C()
    {
        int left = 0;
        int right = 0;
        long sum = 0;
        for (; right < N; right++)
        {
            if (sum == 777) return true;
            sum += Train[right];
            if (sum == 777) return true;
            if (sum > 777)
            {
                for (; left <= right; left++)
                {
                    sum -= Train[left];
                    if (sum == 777) return true;
                    if (sum <= 777) break;
                }
                if (sum == 777) return true;
            }

        }
        return false;
    }

    static public void Main()
    {
        new Program().Solve();
    }
}
0