結果

問題 No.2852 Yakitori Optimization Problem
ユーザー dyktr_06dyktr_06
提出日時 2024-05-09 22:54:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 672 bytes
コンパイル時間 2,185 ms
コンパイル使用メモリ 209,436 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-05-09 22:54:42
合計ジャッジ時間 4,834 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
5,248 KB
testcase_01 AC 64 ms
6,016 KB
testcase_02 AC 53 ms
5,504 KB
testcase_03 AC 96 ms
7,040 KB
testcase_04 AC 90 ms
6,400 KB
testcase_05 AC 30 ms
5,376 KB
testcase_06 AC 10 ms
5,376 KB
testcase_07 AC 68 ms
6,272 KB
testcase_08 AC 8 ms
5,376 KB
testcase_09 AC 86 ms
7,040 KB
testcase_10 AC 91 ms
7,168 KB
testcase_11 AC 92 ms
7,168 KB
testcase_12 AC 93 ms
7,040 KB
testcase_13 AC 91 ms
7,040 KB
testcase_14 AC 92 ms
7,168 KB
testcase_15 AC 91 ms
7,040 KB
testcase_16 AC 93 ms
7,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;
    vector<int> a(n), b(n), c(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; i++) cin >> c[i];

    vector<pair<int, int>> p(n);
    for(int i = 0; i < n; i++) p[i] = {b[i] - c[i], i};
    sort(p.rbegin(), p.rend());

    long long ans = 0;
    for(int i = 0; i < n; i++){
        int idx = p[i].second;
        if(i < k){
            ans += a[idx] + b[idx];
        }else{
            ans += a[idx] + c[idx];
        }
    }
    cout << ans << "\n";
}
0