結果

問題 No.2852 Yakitori Optimization Problem
ユーザー Tatsu_mrTatsu_mr
提出日時 2024-08-25 13:59:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 209,440 KB
実行使用メモリ 10,272 KB
最終ジャッジ日時 2024-08-25 14:00:04
合計ジャッジ時間 6,382 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
6,812 KB
testcase_01 AC 166 ms
8,800 KB
testcase_02 AC 140 ms
7,348 KB
testcase_03 AC 226 ms
10,036 KB
testcase_04 AC 187 ms
9,120 KB
testcase_05 AC 71 ms
6,940 KB
testcase_06 AC 24 ms
6,940 KB
testcase_07 AC 193 ms
9,088 KB
testcase_08 AC 18 ms
6,940 KB
testcase_09 AC 227 ms
9,872 KB
testcase_10 AC 239 ms
10,144 KB
testcase_11 AC 234 ms
10,268 KB
testcase_12 AC 244 ms
10,272 KB
testcase_13 AC 241 ms
10,144 KB
testcase_14 AC 243 ms
10,140 KB
testcase_15 AC 231 ms
10,140 KB
testcase_16 AC 243 ms
10,148 KB
権限があれば一括ダウンロードができます

ソースコード

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