結果
問題 | No.1471 Sort Queries |
ユーザー |
![]() |
提出日時 | 2021-04-13 13:02:46 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 164 ms / 2,000 ms |
コード長 | 1,550 bytes |
コンパイル時間 | 2,396 ms |
コンパイル使用メモリ | 77,944 KB |
実行使用メモリ | 44,608 KB |
最終ジャッジ日時 | 2024-06-29 13:44:43 |
合計ジャッジ時間 | 8,483 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int q = sc.nextInt(); int[][] sums = new int[n + 1][]; sums[0] = new int[26]; char[] arr = sc.next().toCharArray(); for (int i =1; i <= n; i++) { sums[i] = (int[])(sums[i - 1].clone()); sums[i][arr[i - 1] - 'a']++; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int left = sc.nextInt() - 1; int right = sc.nextInt(); int x = sc.nextInt(); for (int j = 0; j < 26; j++) { x -= sums[right][j] - sums[left][j]; if (x <= 0) { sb.append((char)(j + 'a')).append("\n"); break; } } } System.out.print(sb); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }