結果

問題 No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia
ユーザー tentententen
提出日時 2021-11-01 15:24:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 813 ms / 2,000 ms
コード長 1,922 bytes
コンパイル時間 2,120 ms
コンパイル使用メモリ 77,884 KB
実行使用メモリ 68,544 KB
最終ジャッジ日時 2024-04-18 11:40:57
合計ジャッジ時間 22,770 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
37,356 KB
testcase_01 AC 49 ms
37,304 KB
testcase_02 AC 48 ms
37,124 KB
testcase_03 AC 47 ms
37,344 KB
testcase_04 AC 52 ms
37,028 KB
testcase_05 AC 48 ms
36,796 KB
testcase_06 AC 50 ms
37,292 KB
testcase_07 AC 50 ms
37,120 KB
testcase_08 AC 53 ms
37,300 KB
testcase_09 AC 50 ms
37,336 KB
testcase_10 AC 50 ms
37,432 KB
testcase_11 AC 76 ms
38,556 KB
testcase_12 AC 56 ms
37,280 KB
testcase_13 AC 79 ms
38,240 KB
testcase_14 AC 78 ms
38,268 KB
testcase_15 AC 54 ms
37,624 KB
testcase_16 AC 417 ms
54,960 KB
testcase_17 AC 656 ms
67,672 KB
testcase_18 AC 516 ms
59,396 KB
testcase_19 AC 344 ms
49,200 KB
testcase_20 AC 314 ms
49,668 KB
testcase_21 AC 692 ms
68,280 KB
testcase_22 AC 813 ms
68,332 KB
testcase_23 AC 665 ms
68,280 KB
testcase_24 AC 634 ms
67,920 KB
testcase_25 AC 646 ms
68,280 KB
testcase_26 AC 754 ms
68,260 KB
testcase_27 AC 667 ms
67,816 KB
testcase_28 AC 774 ms
68,544 KB
testcase_29 AC 667 ms
68,184 KB
testcase_30 AC 655 ms
68,456 KB
testcase_31 AC 664 ms
68,244 KB
testcase_32 AC 453 ms
67,548 KB
testcase_33 AC 430 ms
67,556 KB
testcase_34 AC 527 ms
65,344 KB
testcase_35 AC 509 ms
68,388 KB
testcase_36 AC 52 ms
36,888 KB
testcase_37 AC 46 ms
37,432 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;
        long a;
        long b;
        
        public Cosme(int idx, long a) {
            this.idx = idx;
            this.a = a;
        } 
        
        public int compareTo(Cosme another) {
            if (a - b == another.a - another.b) {
                return 0;
            } else if (a - b > another.a - another.b) {
                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 String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0