結果

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

ソースコード

diff #

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

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

    int N,K; cin >> N >> K;
    vector<int> A(N),B(N),C(N);
    for(auto &a : A) cin >> a;
    for(auto &a : B) cin >> a;
    for(auto &a : C) cin >> a;

    long long answer = 0;
    for(auto &a : A) answer += a;
    for(auto &b : B) answer += b;
    vector<int> inc(N);
    for(int i=0; i<N; i++) inc.at(i) = C.at(i)-B.at(i);
    sort(inc.rbegin(),inc.rend());
    for(int i=0; i<N-K; i++) answer += inc.at(i);
    cout << answer << endl;
}
0