超级书架2(计蒜客)
作者:互联网
1 #include<iostream> 2 using namespace std; 3 int cow[25]; 4 int min_high = 0x3f3f3f3f; 5 void dfs(int n,int len,int plus,int b) 6 { 7 if(plus>=b) 8 { 9 if(plus-b<min_high) 10 min_high = plus-b; 11 } 12 else 13 { 14 for(int i=n;i<=len;++i) 15 { 16 dfs(i+1,len,plus+cow[i],b); 17 } 18 } 19 } 20 int main() 21 { 22 int n,b; 23 cin>>n>>b; 24 for(int i=0; i<n;++i) 25 { 26 cin>>cow[i]; 27 } 28 dfs(0,n,0,b); 29 cout<<min_high; 30 return 0; 31 }
标签:cow,书架,int,超级,namespace,dfs,plus,计蒜客,cout 来源: https://www.cnblogs.com/caxi/p/12535182.html