結果

問題 No.1471 Sort Queries
ユーザー tentententen
提出日時 2022-09-30 15:06:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 1,762 bytes
コンパイル時間 4,003 ms
コンパイル使用メモリ 74,088 KB
実行使用メモリ 62,212 KB
最終ジャッジ日時 2023-08-24 05:22:39
合計ジャッジ時間 8,698 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,272 KB
testcase_01 AC 42 ms
49,272 KB
testcase_02 AC 42 ms
49,160 KB
testcase_03 AC 45 ms
49,332 KB
testcase_04 AC 45 ms
49,048 KB
testcase_05 AC 47 ms
49,184 KB
testcase_06 AC 45 ms
49,048 KB
testcase_07 AC 44 ms
49,144 KB
testcase_08 AC 44 ms
49,016 KB
testcase_09 AC 43 ms
49,020 KB
testcase_10 AC 43 ms
49,180 KB
testcase_11 AC 44 ms
49,264 KB
testcase_12 AC 45 ms
49,572 KB
testcase_13 AC 113 ms
53,000 KB
testcase_14 AC 103 ms
52,292 KB
testcase_15 AC 120 ms
53,104 KB
testcase_16 AC 114 ms
52,564 KB
testcase_17 AC 104 ms
52,108 KB
testcase_18 AC 84 ms
49,332 KB
testcase_19 AC 111 ms
52,436 KB
testcase_20 AC 126 ms
53,016 KB
testcase_21 AC 105 ms
52,044 KB
testcase_22 AC 97 ms
52,048 KB
testcase_23 AC 139 ms
58,848 KB
testcase_24 AC 124 ms
58,824 KB
testcase_25 AC 149 ms
57,684 KB
testcase_26 AC 130 ms
56,956 KB
testcase_27 AC 161 ms
60,088 KB
testcase_28 AC 145 ms
59,512 KB
testcase_29 AC 137 ms
56,064 KB
testcase_30 AC 135 ms
58,012 KB
testcase_31 AC 137 ms
55,360 KB
testcase_32 AC 156 ms
59,004 KB
testcase_33 AC 156 ms
61,120 KB
testcase_34 AC 164 ms
58,048 KB
testcase_35 AC 198 ms
62,212 KB
testcase_36 AC 159 ms
59,320 KB
testcase_37 AC 155 ms
58,828 KB
testcase_38 AC 174 ms
56,584 KB
testcase_39 AC 156 ms
60,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
        char[] values = sc.next().toCharArray();
        int[][] sums = new int[n + 1][26];
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < 26; j++) {
                sums[i][j] = sums[i - 1][j];
            }
            sums[i][values[i - 1] - 'a']++;
        }
        StringBuilder sb = new StringBuilder();
        while (q-- > 0) {
            int left = sc.nextInt();
            int right = sc.nextInt();
            int x = sc.nextInt();
            int count = 0;
            for (int i = 0; i < 26; i++) {
                count += sums[right][i] - sums[left - 1][i];
                if (count >= x) {
                    sb.append((char)(i + 'a')).append("\n");
                    break;
                }
            }
        }
        System.out.print(sb);
    }
}
    
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 String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0