結果

問題 No.2401 Dirty Shoes and Stairs
ユーザー bluemegane
提出日時 2023-08-05 07:46:07
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 983 bytes
コンパイル時間 2,422 ms
コンパイル使用メモリ 105,728 KB
実行使用メモリ 34,560 KB
最終ジャッジ日時 2024-10-15 05:22:24
合計ジャッジ時間 3,561 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Linq;
using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var an = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var bn = int.Parse(Console.ReadLine().Trim());
        line = Console.ReadLine().Trim().Split(' ');
        var b = Array.ConvertAll(line, int.Parse);
        getAns(n, an, a, bn, b);
    }
    static void calc(int n, int aL, int[] a, bool[] c)
    {
        var p = 0;
        c[p] = true;
        for (int i = 0; i < aL; i++)
        {
            p += a[i];
            c[p] = true;
        }
    }
    static void getAns(int n, int an, int[] a, int bn, int[] b)
    {
        var c = new bool[n + 1];
        calc(n, an, a, c);
        Array.Reverse(b);
        calc(n, bn, b, c);
        var ans = c.Count(x => x == false);
        Console.WriteLine(ans);
    }
}
0