結果

問題 No.871 かえるのうた
ユーザー kekurekekure
提出日時 2019-10-12 22:14:09
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 1,467 bytes
コンパイル時間 4,786 ms
コンパイル使用メモリ 103,772 KB
実行使用メモリ 49,092 KB
最終ジャッジ日時 2023-08-20 09:29:54
合計ジャッジ時間 10,741 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
21,900 KB
testcase_01 AC 64 ms
21,820 KB
testcase_02 AC 65 ms
23,952 KB
testcase_03 AC 65 ms
21,928 KB
testcase_04 AC 65 ms
21,908 KB
testcase_05 AC 63 ms
19,952 KB
testcase_06 AC 65 ms
21,800 KB
testcase_07 AC 64 ms
21,844 KB
testcase_08 AC 74 ms
24,384 KB
testcase_09 AC 74 ms
22,512 KB
testcase_10 AC 73 ms
22,028 KB
testcase_11 AC 73 ms
22,220 KB
testcase_12 AC 84 ms
23,692 KB
testcase_13 AC 76 ms
22,700 KB
testcase_14 AC 179 ms
46,548 KB
testcase_15 AC 177 ms
49,092 KB
testcase_16 AC 187 ms
47,860 KB
testcase_17 AC 169 ms
47,068 KB
testcase_18 AC 87 ms
24,276 KB
testcase_19 AC 179 ms
47,228 KB
testcase_20 AC 79 ms
23,040 KB
testcase_21 AC 113 ms
36,288 KB
testcase_22 AC 65 ms
23,960 KB
testcase_23 AC 65 ms
23,868 KB
testcase_24 AC 64 ms
21,892 KB
testcase_25 AC 73 ms
22,268 KB
testcase_26 AC 79 ms
23,060 KB
testcase_27 AC 81 ms
23,136 KB
testcase_28 AC 65 ms
21,988 KB
testcase_29 AC 115 ms
37,504 KB
testcase_30 AC 136 ms
42,008 KB
testcase_31 AC 74 ms
22,472 KB
testcase_32 AC 129 ms
40,352 KB
testcase_33 AC 162 ms
49,036 KB
testcase_34 AC 90 ms
28,596 KB
testcase_35 AC 124 ms
39,636 KB
testcase_36 AC 141 ms
43,648 KB
testcase_37 AC 117 ms
36,576 KB
testcase_38 AC 171 ms
46,420 KB
testcase_39 AC 165 ms
41,184 KB
testcase_40 AC 108 ms
30,940 KB
testcase_41 AC 64 ms
21,776 KB
testcase_42 AC 109 ms
32,092 KB
testcase_43 AC 65 ms
21,864 KB
testcase_44 AC 65 ms
21,916 KB
testcase_45 AC 74 ms
24,196 KB
testcase_46 AC 65 ms
23,864 KB
testcase_47 AC 64 ms
23,900 KB
testcase_48 AC 64 ms
21,916 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 FreeWorks
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int n = int.Parse(line[0]);
            int k = int.Parse(line[1]);
            long[] X = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            long[] A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            bool[] check = new bool[n];


            Queue<int> q = new Queue<int>();
            q.Enqueue(k - 1);
            int cnt = 0;
            int max_i = k - 1;
            int min_i = k - 1;
            while (q.Count > 0)
            {
                int i = q.Dequeue();
                if (check[i]) continue;
                check[i] = true;
                cnt++;
                long rightRange = X[i] + A[i];
                long leftRange = X[i] - A[i];

                for (int x = max_i + 1; x < n && X[x] <= rightRange; x++)
                {
                    q.Enqueue(x);
                    max_i = Math.Max(max_i, x);
                }

                for (int x = min_i - 1; x >= 0 && leftRange <= X[x]; x--)
                {
                    q.Enqueue(x);
                    min_i = Math.Min(min_i, x);
                }

            }

            Console.WriteLine(cnt);
        }
    }
}
0