Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 20;
- vector< int > p;
- int n ,g;
- int main()
- {
- scanf("%d%d" ,&n ,&g); p.resize(n);
- for(auto &i : p) scanf("%d" ,&i);
- int totalPoint = 0 ,numOfElement = 0 ,Sum = 0; {
- vector< int > tmp = p;
- sort(tmp.begin() ,tmp.end() ,greater< int >());
- for(auto i : tmp) totalPoint += i;
- for(auto i : tmp)
- {
- Sum += i;
- numOfElement += 1;
- if( 100 * Sum / totalPoint >= g ) break;
- }
- }
- vector< vector< int > > Ans;
- for(int Mask = 0 ; Mask <= (1 << n) ; Mask += 1)
- {
- int tmpMask = Mask;
- vector< int > idx;
- while( tmpMask )
- {
- int fd = (tmpMask & -tmpMask);
- idx.push_back( log2(fd) );
- tmpMask -= fd;
- }
- if( (int)idx.size() == numOfElement )
- {
- Sum = 0;
- for(auto i : idx) Sum += p[i];
- if( 100 * Sum / totalPoint >= g )
- {
- Ans.push_back( vector< int >() );
- Ans.back().push_back(100 * Sum / totalPoint);
- for(auto i : idx) Ans.back().push_back(i + 1);
- }
- }
- }
- printf("%d %d\n" ,numOfElement ,(int)Ans.size());
- for(auto i : Ans){
- for(auto j : i)
- printf("%d " ,j);
- puts("");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement