Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define OO INT_MAX
- vector< int > ClassA ,ClassB;
- const int N = 1e2 + 2e1;
- int n ,arr[N];
- int main() {
- cin >> n;
- for(int i = 0 ; i < n ; i++)
- cin >> arr[i];
- sort(arr , arr + n);
- int SumA = 0 ,SumB = 0;
- for(int i = 0 ; i < n ; i++){
- if( SumA < SumB ) {
- SumA += arr[i];
- ClassA.push_back( arr[i] );
- } else {
- SumB += arr[i];
- ClassB.push_back( arr[i] );
- }
- }
- cout << "First Class: " << SumA << endl;
- for(auto i : ClassA ) cout << i << ' ';
- cout << endl;
- cout << "Second Class: " << SumA << endl;
- for(auto i : ClassA ) cout << i << ' ' ;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement