結果
問題 | No.935 う し た ぷ に き あ く ん 笑 ビ - ム |
ユーザー | tenten |
提出日時 | 2023-08-01 13:52:09 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 497 ms / 2,000 ms |
コード長 | 2,697 bytes |
コンパイル時間 | 2,618 ms |
コンパイル使用メモリ | 92,740 KB |
実行使用メモリ | 60,392 KB |
最終ジャッジ日時 | 2024-10-11 05:34:35 |
合計ジャッジ時間 | 19,070 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 106 ms
51,740 KB |
testcase_01 | AC | 177 ms
56,668 KB |
testcase_02 | AC | 186 ms
57,364 KB |
testcase_03 | AC | 270 ms
58,032 KB |
testcase_04 | AC | 317 ms
58,688 KB |
testcase_05 | AC | 251 ms
58,516 KB |
testcase_06 | AC | 265 ms
58,532 KB |
testcase_07 | AC | 303 ms
58,512 KB |
testcase_08 | AC | 405 ms
57,976 KB |
testcase_09 | AC | 319 ms
57,972 KB |
testcase_10 | AC | 355 ms
58,088 KB |
testcase_11 | AC | 481 ms
58,344 KB |
testcase_12 | AC | 57 ms
50,252 KB |
testcase_13 | AC | 55 ms
50,388 KB |
testcase_14 | AC | 56 ms
50,020 KB |
testcase_15 | AC | 57 ms
50,304 KB |
testcase_16 | AC | 56 ms
50,312 KB |
testcase_17 | AC | 320 ms
55,632 KB |
testcase_18 | AC | 388 ms
58,608 KB |
testcase_19 | AC | 274 ms
58,392 KB |
testcase_20 | AC | 375 ms
57,756 KB |
testcase_21 | AC | 123 ms
54,304 KB |
testcase_22 | AC | 231 ms
57,480 KB |
testcase_23 | AC | 59 ms
50,132 KB |
testcase_24 | AC | 109 ms
52,460 KB |
testcase_25 | AC | 110 ms
52,784 KB |
testcase_26 | AC | 98 ms
51,436 KB |
testcase_27 | AC | 61 ms
50,520 KB |
testcase_28 | AC | 81 ms
50,956 KB |
testcase_29 | AC | 99 ms
52,284 KB |
testcase_30 | AC | 93 ms
51,832 KB |
testcase_31 | AC | 75 ms
51,176 KB |
testcase_32 | AC | 102 ms
52,592 KB |
testcase_33 | AC | 394 ms
58,264 KB |
testcase_34 | AC | 409 ms
58,456 KB |
testcase_35 | AC | 369 ms
58,564 KB |
testcase_36 | AC | 274 ms
58,472 KB |
testcase_37 | AC | 385 ms
58,352 KB |
testcase_38 | AC | 261 ms
60,392 KB |
testcase_39 | AC | 371 ms
57,876 KB |
testcase_40 | AC | 343 ms
57,828 KB |
testcase_41 | AC | 385 ms
58,840 KB |
testcase_42 | AC | 382 ms
58,644 KB |
testcase_43 | AC | 379 ms
59,184 KB |
testcase_44 | AC | 172 ms
57,556 KB |
testcase_45 | AC | 426 ms
58,992 KB |
testcase_46 | AC | 152 ms
55,356 KB |
testcase_47 | AC | 232 ms
57,700 KB |
testcase_48 | AC | 323 ms
58,064 KB |
testcase_49 | AC | 259 ms
58,748 KB |
testcase_50 | AC | 343 ms
58,692 KB |
testcase_51 | AC | 315 ms
58,436 KB |
testcase_52 | AC | 278 ms
58,868 KB |
testcase_53 | AC | 497 ms
58,440 KB |
testcase_54 | AC | 318 ms
58,536 KB |
testcase_55 | AC | 102 ms
53,504 KB |
testcase_56 | AC | 359 ms
58,552 KB |
testcase_57 | AC | 284 ms
58,624 KB |
testcase_58 | AC | 55 ms
50,412 KB |
testcase_59 | AC | 55 ms
50,160 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); char[] inputs = sc.next().toCharArray(); int[] enemies = new int[n + 1]; long[] sums = new long[n + 1]; for (int i = 1; i <= n; i++) { sums[i] = sums[i - 1] + sc.nextInt(); enemies[i] = enemies[i - 1]; if (inputs[i - 1] == 'E') { enemies[i]++; } } TreeMap<Long, Integer> counts = new TreeMap<>(); counts.put(0L, 0); for (int i = 0; i < n; i++) { for (int j = i + 1; j <= n; j++) { Long x = sums[j] - sums[i]; int y = enemies[j] - enemies[i]; if (counts.floorEntry(x).getValue() >= y) { continue; } counts.put(x, y); while ((x = counts.higherKey(x)) != null) { if (counts.get(x) <= y) { counts.remove(x); } else { break; } } } } int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); while(q-- > 0) { sb.append(counts.floorEntry(sc.nextLong()).getValue()).append("\n"); } System.out.print(sb); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }