結果

問題 No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia
ユーザー Varun TejaVarun Teja
提出日時 2021-10-29 22:17:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,433 bytes
コンパイル時間 2,082 ms
コンパイル使用メモリ 171,396 KB
実行使用メモリ 12,464 KB
最終ジャッジ日時 2024-04-16 15:08:07
合計ジャッジ時間 13,196 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 100 ms
5,376 KB
testcase_17 AC 184 ms
6,824 KB
testcase_18 AC 141 ms
6,392 KB
testcase_19 AC 58 ms
5,376 KB
testcase_20 AC 64 ms
5,376 KB
testcase_21 AC 196 ms
6,964 KB
testcase_22 AC 193 ms
6,964 KB
testcase_23 AC 195 ms
7,088 KB
testcase_24 AC 194 ms
7,092 KB
testcase_25 AC 196 ms
6,964 KB
testcase_26 AC 194 ms
6,968 KB
testcase_27 AC 196 ms
6,904 KB
testcase_28 AC 194 ms
6,964 KB
testcase_29 AC 196 ms
7,092 KB
testcase_30 AC 196 ms
7,096 KB
testcase_31 AC 193 ms
6,964 KB
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main() {
    int n, k; cin >> n >> k; int A[n], B[n], i, j;
    for(i = 0; i < n; i++)  cin >> A[i];
    for(i = 0; i < n; i++)  cin >> B[i];
    int cnt = 0; long long sm = 0; int diff[n];
    string str(n, 'a');
    for(i = 0; i < n; i++) {
        if(A[i] >= B[i]) cnt++;
        diff[i] = A[i] - B[i];
    }
    if(k > cnt) {
        priority_queue<pair<int, int>, vector<pair<int, int>>, 
            greater<pair<int, int>>> pq;
        for(i = 0; i < n; i++) {
            if(A[i] >= B[i])        str[i] = 'A';
            else if(B[i] > A[i])    pq.push({diff[i], i});
        }
        i = 0;
        while(i < n - k) {
            pair<int, int> pii = pq.top(); pq.pop();
            str[pii.second] = 'B';
            i++;
        }
        while(!pq.empty()) {
            pair<int, int> pii = pq.top(); pq.pop();
            str[pii.second] = 'A';
        }
    } else {
        priority_queue<pair<int, int>> pq;
        for(i = 0; i < n; i++) {
            if(B[i] >= A[i]) str[i] = 'B';
            else             pq.push({diff[i], i});
        }
        i = 0;
        while(i < k) {
            pair<int, int> pii = pq.top(); pq.pop();
            str[pii.second] = 'A';
            i++;
        }
        while(!pq.empty()) {
            pair<int, int> pii = pq.top(); pq.pop();
            str[pii.second] = 'B';
        }
    }
    cout << str;
    return 0;
}
0