結果

問題 No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia
ユーザー tentententen
提出日時 2022-08-09 08:35:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 893 ms / 2,000 ms
コード長 1,937 bytes
コンパイル時間 3,237 ms
コンパイル使用メモリ 78,148 KB
実行使用メモリ 77,956 KB
最終ジャッジ日時 2023-10-19 19:43:34
合計ジャッジ時間 27,894 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
36,624 KB
testcase_01 AC 53 ms
36,656 KB
testcase_02 AC 53 ms
36,584 KB
testcase_03 AC 53 ms
36,608 KB
testcase_04 AC 53 ms
36,600 KB
testcase_05 AC 53 ms
36,612 KB
testcase_06 AC 55 ms
36,608 KB
testcase_07 AC 57 ms
36,644 KB
testcase_08 AC 57 ms
36,656 KB
testcase_09 AC 55 ms
36,640 KB
testcase_10 AC 54 ms
36,628 KB
testcase_11 AC 81 ms
37,684 KB
testcase_12 AC 60 ms
36,668 KB
testcase_13 AC 84 ms
37,508 KB
testcase_14 AC 86 ms
37,728 KB
testcase_15 AC 62 ms
36,856 KB
testcase_16 AC 529 ms
55,348 KB
testcase_17 AC 793 ms
62,804 KB
testcase_18 AC 629 ms
56,156 KB
testcase_19 AC 396 ms
63,372 KB
testcase_20 AC 378 ms
63,056 KB
testcase_21 AC 824 ms
77,036 KB
testcase_22 AC 797 ms
76,968 KB
testcase_23 AC 828 ms
73,744 KB
testcase_24 AC 856 ms
73,888 KB
testcase_25 AC 820 ms
75,928 KB
testcase_26 AC 836 ms
77,956 KB
testcase_27 AC 865 ms
73,736 KB
testcase_28 AC 893 ms
72,760 KB
testcase_29 AC 846 ms
76,900 KB
testcase_30 AC 810 ms
72,888 KB
testcase_31 AC 824 ms
74,164 KB
testcase_32 AC 562 ms
76,352 KB
testcase_33 AC 549 ms
75,500 KB
testcase_34 AC 576 ms
76,884 KB
testcase_35 AC 586 ms
76,992 KB
testcase_36 AC 55 ms
53,400 KB
testcase_37 AC 56 ms
52,332 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 k = sc.nextInt();
        Cosme[] cosmes = new Cosme[n];
        for (int i = 0; i < n; i++) {
            cosmes[i] = new Cosme(i, sc.nextInt());
        }
        for (int i = 0; i < n; i++) {
            cosmes[i].b = sc.nextInt();
        }
        Arrays.sort(cosmes);
        char[] ans = new char[n];
        for (int i = 0; i < n; i++) {
            if (i < k) {
                ans[cosmes[i].idx] = 'A' ;
            } else {
                ans[cosmes[i].idx] = 'B';
            }
        }
        System.out.println(ans);
    }
    
    static class Cosme implements Comparable<Cosme> {
        int idx;
        int a;
        int b;
        
        public Cosme(int idx, int a) {
            this.idx = idx;
            this.a = a;
        }
        
        public int compareTo(Cosme another) {
            if (b - a == another.b - another.a) {
                return 0;
            } else if (b - a < another.b - another.a) {
                return -1;
            } else {
                return 1;
            }
        }
    }
}

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 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