Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
123762 | 周歆童(初一23 | 健康的奶牛 | C++ | 解答错误 | 90 | 5 MS | 252 KB | 824 | 2024-01-23 09:41:44 |
#include<bits/stdc++.h> using namespace std; int v,wtm[26],g,sl[16][26],ans=0x7fffffff; bool used[16],ansuse[16]; void dfs(int depth){ if(depth>g){ int cnt=0,sum[26]; memset(sum,0,sizeof(sum)); for(int i=1;i<=g;i++){ if(used[i]){ cnt++; for(int j=1;j<=v;j++){ sum[j]+=sl[i][j]; } } } for(int i=1;i<=v;i++){ if(sum[i]<wtm[i])return; } if(cnt<ans){ ans=cnt; for(int i=1;i<=g;i++){ ansuse[i]=used[i]; } } return; } used[depth]=1; dfs(depth+1); used[depth]=0; dfs(depth+1); } int main(){ cin>>v; for(int i=1;i<=v;i++){ cin>>wtm[i]; } cin>>g; for(int i=1;i<=g;i++){ for(int j=1;j<=v;j++){ cin>>sl[i][j]; } } dfs(1); cout<<ans<<" "; for(int i=1;i<=v;i++){ if(ansuse[i])cout<<i<<" "; } return 0; }