#include #include #include using namespace std; bool myfunction (pair i , pair j) { return (i.first > bile; cin >> N >> M; for(int i = 0; i < N; i++) { cin >> wi >> bi; bile.push_back(make_pair(wi,bi)); } std::sort(bile.begin(), bile.end(), myfunction); for(int i = 0; i < N/2; i++) sumw += bile[i].second; for (int i = N/2; i < N; i++) sumb += bile[i].first; cout << sumw << " " << sumb; return 0; }