結果
問題 | No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia |
ユーザー |
![]() |
提出日時 | 2021-10-29 21:39:43 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 672 ms / 2,000 ms |
コード長 | 1,038 bytes |
コンパイル時間 | 2,441 ms |
コンパイル使用メモリ | 80,376 KB |
実行使用メモリ | 80,780 KB |
最終ジャッジ日時 | 2024-10-07 10:28:04 |
合計ジャッジ時間 | 21,081 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 38 |
ソースコード
import java.io.BufferedReader;import java.io.InputStreamReader;import java.util.Arrays;import java.util.PriorityQueue;public class Main {public static void main(String[] args) throws Exception {BufferedReader br = new BufferedReader(new InputStreamReader(System.in));String[] sa = br.readLine().split(" ");int n = Integer.parseInt(sa[0]);int k = Integer.parseInt(sa[1]);sa = br.readLine().split(" ");Obj[] arr = new Obj[n];for (int i = 0; i < n; i++) {Obj o = new Obj();o.i = i;o.a = Integer.parseInt(sa[i]);arr[i] = o;}PriorityQueue<Obj> que = new PriorityQueue<>((o1, o2) -> Long.compare(o2.v, o1.v));sa = br.readLine().split(" ");for (int i = 0; i < n; i++) {Obj o = arr[i];o.b = Integer.parseInt(sa[i]);o.v = o.a - o.b;que.add(o);}br.close();char[] ans = new char[n];Arrays.fill(ans, 'B');for (int i = 0; i < k; i++) {Obj o = que.poll();ans[o.i] = 'A';}System.out.println(ans);}static class Obj {int i, a, b;long v;}}