結果

問題 No.2852 Yakitori Optimization Problem
ユーザー soumatsoumat
提出日時 2024-08-25 13:36:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 699 bytes
コンパイル時間 2,081 ms
コンパイル使用メモリ 209,236 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-08-25 13:36:49
合計ジャッジ時間 6,544 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
6,812 KB
testcase_01 AC 180 ms
7,680 KB
testcase_02 AC 151 ms
6,940 KB
testcase_03 AC 238 ms
9,344 KB
testcase_04 AC 192 ms
8,064 KB
testcase_05 AC 74 ms
6,940 KB
testcase_06 AC 25 ms
6,944 KB
testcase_07 AC 191 ms
8,064 KB
testcase_08 AC 18 ms
6,940 KB
testcase_09 AC 247 ms
9,216 KB
testcase_10 AC 253 ms
9,472 KB
testcase_11 AC 248 ms
9,472 KB
testcase_12 AC 250 ms
9,472 KB
testcase_13 AC 255 ms
9,472 KB
testcase_14 AC 255 ms
9,600 KB
testcase_15 AC 250 ms
9,472 KB
testcase_16 AC 257 ms
9,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(void) {
    int n,k;
    cin >> n >> k;

    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> 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];

    // aは総和で良い
    // bとcはどちらを選ぶか
    // 差が大事

    ll ans = accumulate(a.begin(),a.end(),0ll) + accumulate(c.begin(),c.end(),0ll);

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

    cout << ans << endl;

    
    return 0;
}
0