結果

問題 No.2852 Yakitori Optimization Problem
ユーザー ayataka5ayataka5
提出日時 2024-08-25 13:35:53
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 3,111 ms
コンパイル使用メモリ 258,136 KB
実行使用メモリ 11,076 KB
最終ジャッジ日時 2024-08-25 13:36:08
合計ジャッジ時間 7,908 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
6,816 KB
testcase_01 AC 215 ms
8,832 KB
testcase_02 AC 155 ms
7,808 KB
testcase_03 AC 255 ms
10,792 KB
testcase_04 AC 205 ms
9,344 KB
testcase_05 AC 77 ms
6,944 KB
testcase_06 AC 26 ms
6,944 KB
testcase_07 AC 204 ms
9,216 KB
testcase_08 AC 20 ms
6,944 KB
testcase_09 AC 277 ms
10,752 KB
testcase_10 AC 259 ms
10,968 KB
testcase_11 AC 260 ms
11,008 KB
testcase_12 AC 258 ms
11,008 KB
testcase_13 AC 261 ms
10,976 KB
testcase_14 AC 261 ms
11,008 KB
testcase_15 AC 260 ms
11,040 KB
testcase_16 AC 259 ms
11,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int N, K;
    cin >> N >> K;
    vector A(N, 0LL), B(N, 0LL), C(N, 0LL);
    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 D(N, make_pair(0LL, 0));
    for(int i = 0; i < N; i++) D[i] = {B[i]-C[i], i};
    sort(rbegin(D), rend(D));
    long long ans(0LL);
    for(int i = 0; i < N; i++) {
        int ni = D[i].second;
        if(i < K) {
            ans += A[ni] + B[ni];
        }else {
            ans += A[ni] + C[ni];
        }
    }
    cout << ans << endl;
    return 0;
}
0