結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー tsushimatsushima
提出日時 2019-11-30 10:16:40
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 270 ms / 2,000 ms
コード長 1,385 bytes
コンパイル時間 1,110 ms
コンパイル使用メモリ 70,076 KB
実行使用メモリ 24,028 KB
最終ジャッジ日時 2023-10-12 06:40:08
合計ジャッジ時間 11,415 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
21,828 KB
testcase_01 AC 103 ms
23,868 KB
testcase_02 AC 70 ms
23,692 KB
testcase_03 AC 107 ms
21,904 KB
testcase_04 AC 113 ms
21,804 KB
testcase_05 AC 72 ms
21,680 KB
testcase_06 AC 152 ms
23,864 KB
testcase_07 AC 146 ms
22,032 KB
testcase_08 AC 257 ms
21,936 KB
testcase_09 AC 186 ms
23,832 KB
testcase_10 AC 203 ms
24,016 KB
testcase_11 AC 249 ms
24,028 KB
testcase_12 AC 60 ms
21,656 KB
testcase_13 AC 61 ms
23,792 KB
testcase_14 AC 60 ms
21,668 KB
testcase_15 AC 60 ms
23,624 KB
testcase_16 AC 59 ms
19,620 KB
testcase_17 AC 270 ms
21,876 KB
testcase_18 AC 108 ms
19,908 KB
testcase_19 AC 183 ms
22,000 KB
testcase_20 AC 149 ms
21,892 KB
testcase_21 AC 81 ms
21,848 KB
testcase_22 AC 69 ms
21,780 KB
testcase_23 AC 67 ms
21,696 KB
testcase_24 AC 66 ms
21,740 KB
testcase_25 AC 69 ms
19,660 KB
testcase_26 AC 70 ms
21,692 KB
testcase_27 AC 64 ms
21,728 KB
testcase_28 AC 65 ms
23,632 KB
testcase_29 AC 72 ms
21,720 KB
testcase_30 AC 65 ms
21,728 KB
testcase_31 AC 63 ms
21,664 KB
testcase_32 AC 72 ms
21,776 KB
testcase_33 AC 154 ms
19,848 KB
testcase_34 AC 223 ms
21,884 KB
testcase_35 AC 208 ms
23,992 KB
testcase_36 AC 103 ms
21,880 KB
testcase_37 AC 156 ms
23,944 KB
testcase_38 AC 158 ms
21,976 KB
testcase_39 AC 237 ms
21,876 KB
testcase_40 AC 250 ms
24,016 KB
testcase_41 AC 247 ms
21,940 KB
testcase_42 AC 203 ms
23,940 KB
testcase_43 AC 252 ms
19,920 KB
testcase_44 AC 129 ms
21,892 KB
testcase_45 AC 245 ms
19,980 KB
testcase_46 AC 87 ms
24,004 KB
testcase_47 AC 137 ms
21,896 KB
testcase_48 AC 121 ms
21,812 KB
testcase_49 AC 132 ms
23,852 KB
testcase_50 AC 147 ms
23,948 KB
testcase_51 AC 165 ms
23,968 KB
testcase_52 AC 161 ms
21,908 KB
testcase_53 AC 226 ms
23,932 KB
testcase_54 AC 98 ms
21,808 KB
testcase_55 AC 72 ms
21,820 KB
testcase_56 AC 187 ms
21,932 KB
testcase_57 AC 144 ms
23,948 KB
testcase_58 AC 59 ms
21,668 KB
testcase_59 AC 60 ms
21,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var Q = int.Parse(Console.ReadLine());
            var K = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var acum = new long[N + 1];
            var count = new int[N + 1];

            for (var i = 0; i < N; i++)
            {
                acum[i + 1] = acum[i] + A[i];
                count[i + 1] = count[i] + (S[i] == 'E' ? 1 : 0);
            }

            for (var i = 0; i < Q; i++)
            {
                var ans = 0;
                for (var j = 0; j <= N; j++)
                {
                    var ok = j;
                    var ng = N + 1;

                    while (ng - ok > 1)
                    {
                        var med = (ng + ok) / 2;
                        if (acum[med] - acum[j] <= K[i])
                            ok = med;
                        else
                            ng = med;
                    }

                    ans = Math.Max(ans, count[ok] - count[j]);
                }

                Console.WriteLine(ans);
            }
        }
    }
}
0