結果

問題 No.2852 Yakitori Optimization Problem
ユーザー ripityripity
提出日時 2024-08-25 13:36:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 269 ms / 2,000 ms
コード長 565 bytes
コンパイル時間 4,453 ms
コンパイル使用メモリ 266,956 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-08-25 13:37:13
合計ジャッジ時間 8,894 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
6,816 KB
testcase_01 AC 187 ms
7,680 KB
testcase_02 AC 154 ms
6,940 KB
testcase_03 AC 251 ms
9,344 KB
testcase_04 AC 203 ms
8,064 KB
testcase_05 AC 76 ms
6,944 KB
testcase_06 AC 25 ms
6,944 KB
testcase_07 AC 200 ms
8,064 KB
testcase_08 AC 20 ms
6,940 KB
testcase_09 AC 245 ms
9,344 KB
testcase_10 AC 258 ms
9,472 KB
testcase_11 AC 269 ms
9,472 KB
testcase_12 AC 257 ms
9,472 KB
testcase_13 AC 257 ms
9,472 KB
testcase_14 AC 257 ms
9,472 KB
testcase_15 AC 257 ms
9,600 KB
testcase_16 AC 259 ms
9,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#include <atcoder/all>
using namespace atcoder;

using ll = long long;

int main() {
  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];
  vector<ll> D(N);
  for(int i = 0; i < N; i++) D[i] = B[i] - C[i];
  ll ans = accumulate(A.begin(), A.end(), 0LL) + accumulate(C.begin(), C.end(), 0LL);
  sort(D.rbegin(), D.rend());
  for(int i = 0; i < K; i++) ans += D[i];
  cout << ans << endl;
}
0