結果

問題 No.2852 Yakitori Optimization Problem
ユーザー nononnonon
提出日時 2024-08-25 13:37:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 2,127 ms
コンパイル使用メモリ 205,780 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-08-25 13:37:51
合計ジャッジ時間 4,449 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
6,812 KB
testcase_01 AC 62 ms
6,944 KB
testcase_02 AC 53 ms
6,940 KB
testcase_03 AC 86 ms
6,940 KB
testcase_04 AC 68 ms
6,944 KB
testcase_05 AC 28 ms
6,940 KB
testcase_06 AC 10 ms
6,944 KB
testcase_07 AC 69 ms
6,944 KB
testcase_08 AC 7 ms
6,944 KB
testcase_09 AC 84 ms
6,940 KB
testcase_10 AC 89 ms
6,944 KB
testcase_11 AC 86 ms
6,944 KB
testcase_12 AC 86 ms
6,940 KB
testcase_13 AC 85 ms
6,940 KB
testcase_14 AC 85 ms
6,944 KB
testcase_15 AC 87 ms
6,940 KB
testcase_16 AC 87 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K;
    cin>>N>>K;
    vector<int>D(N);
    long ans=0;
    for(int i=0;i<N;i++)
    {
        int a;
        cin>>a;
        ans+=a;
    }
    vector<int>B(N),C(N);
    for(int i=0;i<N;i++)cin>>B[i];
    for(int i=0;i<N;i++)cin>>C[i],ans+=C[i];
    for(int i=0;i<N;i++)D[i]=B[i]-C[i];
    sort(D.begin(),D.end(),greater());
    for(int i=0;i<K;i++)ans+=D[i];
    cout<<ans<<endl;
}
0