結果
問題 | No.1471 Sort Queries |
ユーザー | tenten |
提出日時 | 2023-04-17 14:40:07 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 174 ms / 2,000 ms |
コード長 | 2,402 bytes |
コンパイル時間 | 3,803 ms |
コンパイル使用メモリ | 91,576 KB |
実行使用メモリ | 50,108 KB |
最終ジャッジ日時 | 2024-10-12 17:12:07 |
合計ジャッジ時間 | 10,044 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 48 ms
37,228 KB |
testcase_01 | AC | 49 ms
37,348 KB |
testcase_02 | AC | 49 ms
37,220 KB |
testcase_03 | AC | 49 ms
37,328 KB |
testcase_04 | AC | 52 ms
36,756 KB |
testcase_05 | AC | 50 ms
37,004 KB |
testcase_06 | AC | 50 ms
36,856 KB |
testcase_07 | AC | 53 ms
37,008 KB |
testcase_08 | AC | 54 ms
37,364 KB |
testcase_09 | AC | 51 ms
37,228 KB |
testcase_10 | AC | 50 ms
37,120 KB |
testcase_11 | AC | 53 ms
37,360 KB |
testcase_12 | AC | 51 ms
37,008 KB |
testcase_13 | AC | 127 ms
43,988 KB |
testcase_14 | AC | 124 ms
44,004 KB |
testcase_15 | AC | 138 ms
45,736 KB |
testcase_16 | AC | 124 ms
40,160 KB |
testcase_17 | AC | 123 ms
43,872 KB |
testcase_18 | AC | 88 ms
39,412 KB |
testcase_19 | AC | 124 ms
40,352 KB |
testcase_20 | AC | 140 ms
45,228 KB |
testcase_21 | AC | 122 ms
42,868 KB |
testcase_22 | AC | 100 ms
40,940 KB |
testcase_23 | AC | 141 ms
44,264 KB |
testcase_24 | AC | 144 ms
46,372 KB |
testcase_25 | AC | 164 ms
49,088 KB |
testcase_26 | AC | 151 ms
47,324 KB |
testcase_27 | AC | 145 ms
43,780 KB |
testcase_28 | AC | 149 ms
47,104 KB |
testcase_29 | AC | 149 ms
46,536 KB |
testcase_30 | AC | 135 ms
44,936 KB |
testcase_31 | AC | 162 ms
48,376 KB |
testcase_32 | AC | 168 ms
48,904 KB |
testcase_33 | AC | 174 ms
49,724 KB |
testcase_34 | AC | 172 ms
49,700 KB |
testcase_35 | AC | 160 ms
44,896 KB |
testcase_36 | AC | 157 ms
49,976 KB |
testcase_37 | AC | 163 ms
49,544 KB |
testcase_38 | AC | 160 ms
45,120 KB |
testcase_39 | AC | 165 ms
50,108 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(); int q = sc.nextInt(); char[] inputs = sc.next().toCharArray(); int[][] counts = new int[n + 1][26]; for (int i = 1; i <= n; i++) { for (int j = 0; j < 26; j++) { counts[i][j] = counts[i - 1][j]; } counts[i][inputs[i - 1] - 'a']++; } StringBuilder sb = new StringBuilder(); while (q-- > 0) { int left = sc.nextInt(); int right = sc.nextInt(); int idx = sc.nextInt(); int[] current = new int[26]; for (int i = 0; i < 26; i++) { current[i] = counts[right][i] - counts[left - 1][i]; } int ans = 0; int value = 0; for (int i = 0; i < 26 && value < idx; i++) { value += current[i]; ans = i; } sb.append((char)(ans + 'a')).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(); } }