結果
問題 | No.935 う し た ぷ に き あ く ん 笑 ビ - ム |
ユーザー | mban |
提出日時 | 2019-11-29 22:15:55 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 156 ms / 2,000 ms |
コード長 | 3,402 bytes |
コンパイル時間 | 854 ms |
コンパイル使用メモリ | 114,560 KB |
実行使用メモリ | 26,640 KB |
最終ジャッジ日時 | 2024-09-14 05:44:56 |
合計ジャッジ時間 | 6,695 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
22,456 KB |
testcase_01 | AC | 57 ms
26,628 KB |
testcase_02 | AC | 33 ms
22,448 KB |
testcase_03 | AC | 63 ms
24,084 KB |
testcase_04 | AC | 60 ms
26,532 KB |
testcase_05 | AC | 34 ms
24,344 KB |
testcase_06 | AC | 96 ms
24,200 KB |
testcase_07 | AC | 82 ms
24,600 KB |
testcase_08 | AC | 156 ms
24,212 KB |
testcase_09 | AC | 107 ms
24,328 KB |
testcase_10 | AC | 120 ms
24,176 KB |
testcase_11 | AC | 152 ms
24,468 KB |
testcase_12 | AC | 26 ms
23,984 KB |
testcase_13 | AC | 25 ms
23,984 KB |
testcase_14 | AC | 26 ms
23,824 KB |
testcase_15 | AC | 25 ms
23,844 KB |
testcase_16 | AC | 27 ms
25,992 KB |
testcase_17 | AC | 151 ms
24,748 KB |
testcase_18 | AC | 59 ms
26,632 KB |
testcase_19 | AC | 117 ms
26,316 KB |
testcase_20 | AC | 86 ms
26,504 KB |
testcase_21 | AC | 38 ms
24,212 KB |
testcase_22 | AC | 32 ms
24,332 KB |
testcase_23 | AC | 30 ms
24,112 KB |
testcase_24 | AC | 30 ms
24,368 KB |
testcase_25 | AC | 32 ms
24,364 KB |
testcase_26 | AC | 30 ms
24,496 KB |
testcase_27 | AC | 27 ms
23,712 KB |
testcase_28 | AC | 27 ms
25,860 KB |
testcase_29 | AC | 32 ms
26,548 KB |
testcase_30 | AC | 28 ms
23,956 KB |
testcase_31 | AC | 28 ms
25,764 KB |
testcase_32 | AC | 32 ms
24,112 KB |
testcase_33 | AC | 87 ms
24,460 KB |
testcase_34 | AC | 133 ms
22,584 KB |
testcase_35 | AC | 121 ms
26,456 KB |
testcase_36 | AC | 49 ms
24,336 KB |
testcase_37 | AC | 87 ms
26,444 KB |
testcase_38 | AC | 96 ms
24,468 KB |
testcase_39 | AC | 138 ms
26,504 KB |
testcase_40 | AC | 148 ms
22,456 KB |
testcase_41 | AC | 147 ms
24,332 KB |
testcase_42 | AC | 118 ms
24,204 KB |
testcase_43 | AC | 152 ms
24,340 KB |
testcase_44 | AC | 73 ms
26,536 KB |
testcase_45 | AC | 151 ms
24,320 KB |
testcase_46 | AC | 42 ms
24,624 KB |
testcase_47 | AC | 77 ms
24,464 KB |
testcase_48 | AC | 65 ms
24,464 KB |
testcase_49 | AC | 76 ms
24,208 KB |
testcase_50 | AC | 81 ms
24,332 KB |
testcase_51 | AC | 93 ms
24,208 KB |
testcase_52 | AC | 91 ms
26,560 KB |
testcase_53 | AC | 135 ms
26,640 KB |
testcase_54 | AC | 51 ms
24,208 KB |
testcase_55 | AC | 35 ms
26,156 KB |
testcase_56 | AC | 111 ms
24,684 KB |
testcase_57 | AC | 81 ms
24,596 KB |
testcase_58 | AC | 25 ms
23,828 KB |
testcase_59 | AC | 26 ms
23,848 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Text; public class Program { private int N; private char[] S; private int[] A; private int Q; private int[] K; private long[] Sum; private int[] Cnt; public void Solve() { var sc = new Scanner(); N = sc.NextInt(); S = sc.Next().ToCharArray(); A = sc.IntArray(); Q = sc.NextInt(); K = sc.IntArray(); Sum = new long[N + 1]; Cnt = new int[N + 1]; for (int i = 0; i < N; i++) { Sum[i + 1] = Sum[i] + A[i]; Cnt[i + 1] = Cnt[i] + (S[i] == 'E' ? 1 : 0); } var sb = new StringBuilder(); for (int i = 0; i < Q; i++) { sb.AppendLine(Query(K[i]).ToString()); } Console.Write(sb.ToString()); } private int Query(int k) { int ans = 0; // 左端 for (int i = 0; i <= N; i++) { // 右端 int ok = i; int ng = N + 1; while (ng - ok > 1) { int med = (ng + ok) / 2; if (Sum[med] - Sum[i] <= k) { ok = med; } else { ng = med; } } ans = Math.Max(ans, Cnt[ok] - Cnt[i]); } return ans; } public static void Main(string[] args) { new Program().Solve(); } } class Scanner { public Scanner() { _pos = 0; _line = new string[0]; } const char Separator = ' '; private int _pos; private string[] _line; #region スペース区切りで取得 public string Next() { if (_pos >= _line.Length) { _line = Console.ReadLine().Split(Separator); _pos = 0; } return _line[_pos++]; } public int NextInt() { return int.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } #endregion #region 型変換 private int[] ToIntArray(string[] array) { var result = new int[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = int.Parse(array[i]); } return result; } private long[] ToLongArray(string[] array) { var result = new long[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = long.Parse(array[i]); } return result; } private double[] ToDoubleArray(string[] array) { var result = new double[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = double.Parse(array[i]); } return result; } #endregion #region 配列取得 public string[] Array() { if (_pos >= _line.Length) _line = Console.ReadLine().Split(Separator); _pos = _line.Length; return _line; } public int[] IntArray() { return ToIntArray(Array()); } public long[] LongArray() { return ToLongArray(Array()); } public double[] DoubleArray() { return ToDoubleArray(Array()); } #endregion }