Official
B - バランスの取れたチーム / Balanced Team Editorial
by
B - バランスの取れたチーム / Balanced Team Editorial
by
MtSaka
プログラミング能力の合計もデザイン能力の合計も社員を全員選んだ時が最も大きいです。そのため、\(S\) を全社員とした時が総合力が最大となります。
つまり答えは、\(\min (\sum_{i=1}^{N}A_i,\sum_{i=1}^{N}B_i)\) です。
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n), b(n);
for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
cout << min(accumulate(a.begin(), a.end(), 0LL), accumulate(b.begin(), b.end(), 0LL)) << endl;
}
posted:
last update:
