Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main() {
- int N;
- cin >> N;
- vector<int> kravi;
- for (int i = 0; i < N; i++) {
- int cnt, mleko;
- cin >> cnt >> mleko;
- for (int j = 0; j < cnt; j++) {
- kravi.push_back(mleko);
- }
- }
- sort(kravi.begin(), kravi.end());
- int vkkravi = kravi.size();
- int rez = 0;
- for (int i = 0; i < vkkravi / 2; i++) {
- int sega = kravi[i] + kravi[vkkravi - 1 - i];
- rez = max(rez, sega);
- }
- cout << rez << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement