結果
| 問題 |
No.2852 Yakitori Optimization Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-25 13:34:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 108 ms / 2,000 ms |
| コード長 | 807 bytes |
| コンパイル時間 | 2,113 ms |
| コンパイル使用メモリ | 201,500 KB |
| 最終ジャッジ日時 | 2025-02-24 00:47:53 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> istream& operator >> (istream& is, vector<T>& vec) {
for(T& x : vec) is >> x;
return is;
}
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
if(vec.empty()) return os;
os << vec[0];
for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
return os;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<int> a(n), b(n), c(n);
cin >> a >> b >> c;
ll ans = accumulate(a.begin(), a.end(), 0ll);
for(int i = 0; i < n; i++){
ans += c[i];
b[i] = b[i] - c[i];
}
sort(b.rbegin(), b.rend());
for(int i = 0; i < k; i++){
ans += b[i];
}
cout << ans << '\n';
}