結果

問題 No.2852 Yakitori Optimization Problem
ユーザー MMMM
提出日時 2024-08-25 13:35:36
言語 C++23(gcc13)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 271 ms / 2,000 ms
コード長 766 bytes
コンパイル時間 5,746 ms
コンパイル使用メモリ 337,376 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-08-25 13:35:51
合計ジャッジ時間 10,171 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
6,816 KB
testcase_01 AC 183 ms
7,680 KB
testcase_02 AC 155 ms
6,944 KB
testcase_03 AC 250 ms
9,344 KB
testcase_04 AC 203 ms
8,192 KB
testcase_05 AC 76 ms
6,940 KB
testcase_06 AC 26 ms
6,940 KB
testcase_07 AC 198 ms
8,192 KB
testcase_08 AC 19 ms
6,940 KB
testcase_09 AC 271 ms
9,216 KB
testcase_10 AC 255 ms
9,600 KB
testcase_11 AC 257 ms
9,600 KB
testcase_12 AC 248 ms
9,472 KB
testcase_13 AC 252 ms
9,600 KB
testcase_14 AC 248 ms
9,472 KB
testcase_15 AC 268 ms
9,472 KB
testcase_16 AC 250 ms
9,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define chmin(x,y) (x) = min((x),(y))
#define chmax(x,y) (x) = max((x),(y))
using namespace std;
using namespace atcoder;
using ll = long long;
const ll mod = 998244353;
using mint = modint998244353;
using Graph = vector<vector<int>>;

int main(){
  // input
  int N,K; cin >> N >> K;
  vector<ll> 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];
  
  
  // solve
  ll ans = 0;
  vector<ll> D(N);
  for(int i = 0; i < N; i++){
    ans += A[i] + C[i];
    D[i] = B[i] - C[i];
  }
  sort(D.begin(),D.end(),greater<ll>{});
  
  for(int i = 0; i < K; i++)
    ans += D[i];
  
  cout << ans << endl;
  // solve
  
  
  // output
}
0