Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,mini=9999999;
- int a[25];
- cin>>n;
- for (int i=0;i<n;i++)
- cin>>a[i];
- int z=1<<n;
- cout<<z<<endl;
- while (z)
- {
- int sum=0;
- for (int i=0;i<n;i++)
- {
- if (z&(1<<i)) sum+=a[i];
- else sum-=a[i];
- }
- if (sum>=0&&mini>sum) mini=sum;
- z--;
- }
- cout<<mini<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement