結果

問題 No.2401 Dirty Shoes and Stairs
ユーザー InTheBloomInTheBloom
提出日時 2023-08-04 21:28:51
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 4,684 ms
コンパイル使用メモリ 174,464 KB
実行使用メモリ 8,176 KB
最終ジャッジ日時 2024-04-22 19:49:47
合計ジャッジ時間 2,609 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 10 ms
5,376 KB
testcase_04 AC 14 ms
5,632 KB
testcase_05 AC 5 ms
5,376 KB
testcase_06 AC 10 ms
5,376 KB
testcase_07 AC 18 ms
6,764 KB
testcase_08 AC 8 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 7 ms
5,376 KB
testcase_11 AC 26 ms
7,364 KB
testcase_12 AC 21 ms
8,176 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 3 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main () {
    int N = readln.chomp.to!int;
    int M1 = readln.chomp.to!int;
    int[] A = readln.split.to!(int[]);
    int M2 = readln.chomp.to!int;
    int[] B = readln.split.to!(int[]);

    solve(N, M1, A, M2, B);
}

void solve (int N, int M1, int[] A, int M2, int[] B) {
    int[] arr = new int[](N+1);

    // 1 -> 汚れ | 0 -> 汚れてない
    int sum = 0;
    arr[sum] = 1;
    foreach (a; A) {
        sum += a;
        arr[sum] = 1;
    }

    foreach (b; B) {
        sum -= b;
        arr[sum] = 1;
    }

    int ans = 0;
    foreach (a; arr) {
        if (a == 0) {
            ans++;
        }
    }

    writeln(ans);
}
0