結果

問題 No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia
ユーザー tentententen
提出日時 2022-09-28 14:11:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 821 ms / 2,000 ms
コード長 2,099 bytes
コンパイル時間 2,286 ms
コンパイル使用メモリ 74,808 KB
実行使用メモリ 84,148 KB
最終ジャッジ日時 2023-08-24 04:24:18
合計ジャッジ時間 24,066 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,788 KB
testcase_01 AC 41 ms
49,704 KB
testcase_02 AC 42 ms
50,160 KB
testcase_03 AC 42 ms
49,832 KB
testcase_04 AC 42 ms
49,788 KB
testcase_05 AC 42 ms
49,684 KB
testcase_06 AC 43 ms
49,892 KB
testcase_07 AC 45 ms
50,004 KB
testcase_08 AC 44 ms
49,704 KB
testcase_09 AC 44 ms
49,912 KB
testcase_10 AC 44 ms
49,744 KB
testcase_11 AC 59 ms
51,868 KB
testcase_12 AC 50 ms
50,864 KB
testcase_13 AC 61 ms
51,848 KB
testcase_14 AC 74 ms
51,776 KB
testcase_15 AC 53 ms
49,912 KB
testcase_16 AC 447 ms
66,724 KB
testcase_17 AC 774 ms
81,592 KB
testcase_18 AC 579 ms
68,176 KB
testcase_19 AC 351 ms
59,924 KB
testcase_20 AC 350 ms
59,584 KB
testcase_21 AC 765 ms
83,576 KB
testcase_22 AC 765 ms
79,996 KB
testcase_23 AC 759 ms
83,592 KB
testcase_24 AC 807 ms
80,412 KB
testcase_25 AC 765 ms
84,148 KB
testcase_26 AC 764 ms
81,200 KB
testcase_27 AC 776 ms
83,560 KB
testcase_28 AC 762 ms
83,424 KB
testcase_29 AC 755 ms
83,668 KB
testcase_30 AC 821 ms
79,832 KB
testcase_31 AC 769 ms
83,476 KB
testcase_32 AC 508 ms
83,432 KB
testcase_33 AC 511 ms
83,252 KB
testcase_34 AC 532 ms
83,572 KB
testcase_35 AC 535 ms
83,424 KB
testcase_36 AC 42 ms
49,768 KB
testcase_37 AC 43 ms
49,640 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();
        Product[] products = new Product[n];
        for (int i = 0; i < n; i++) {
            products[i] = new Product(i, sc.nextInt());
        }
        for (int i = 0; i < n; i++) {
            products[i].b = sc.nextInt();
        }
        Arrays.sort(products);
        for (int i = 0; i < k; i++) {
            products[i].isA = true;
        }
        char[] ans = new char[n];
        for (Product x : products) {
            if (x.isA) {
                ans[x.idx] = 'A';
            } else {
                ans[x.idx] = 'B';
            }
        }
        System.out.println(ans);
    }
    
    static class Product implements Comparable<Product> {
        int idx;
        int a;
        int b;
        boolean isA;
        
        public Product(int idx, int a) {
            this.idx = idx;
            this.a = a;
        }
        
        public int compareTo(Product 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("");
    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