結果

問題 No.2852 Yakitori Optimization Problem
ユーザー Tatsu_mr
提出日時 2024-08-25 13:59:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 2,181 ms
コンパイル使用メモリ 201,852 KB
最終ジャッジ日時 2025-02-24 01:03:32
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using lint = long long;

int main() {
    int n, k;
    cin >> n >> k;
    vector<lint> 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];
    }
    lint ans = accumulate(a.begin(), a.end(), 0LL) + accumulate(c.begin(), c.end(), 0LL);
    vector<lint> d;
    for (int i = 0; i < n; i++) {
        d.emplace_back(b[i] - c[i]);
    }
    sort(d.rbegin(), d.rend());
    for (int i = 0; i < k; i++) {
        ans += d[i];
    }
    cout << ans << endl;
}
0