#include<iostream>
#include<vector>
#include<algorithm>
#include <string.h>
using namespace std;
const int M = 30;
int v, g;
int p[M];//v
int a[M][M];//g,v
bool st[M];
int temp[M];
bool ac[M];
int minP = 30;
int judge()
{
memset(temp, 0, sizeof(temp));
int x = 0;
for (int i = 0; i < g; i++)
{
if (st[i] == 1)
{
x += 1;
for (int j = 0; j < v; j++)
{
temp[j] += a[i][j];
}
}
}
for (int i = 0; i < v; i++)
{
if (temp[i] < p[i])
{
return -1;
}
}
return x;
}
void dfs(int u)
{
if (u == g)
{
int tempX = judge();
// cout<<tempX<<endl;
if (tempX != -1)
{
if (tempX < minP)
{
minP = tempX;
for (int i = 0; i < g; i++)
{
ac[i] = st[i];
}
}
if (tempX == minP)
{
for (int i = 0; i < g; i++)
{
if (ac[i] != st[i])
{
if(ac[i]==1)
{
break;
}
if (st[i] == 1)
{
for (int j = 0; j < g; j++)
{
ac[j] = st[j];
}
}
break;
}
}
}
}
return;
}
//不放
dfs(u + 1);
st[u] = 1;
dfs(u + 1);
st[u] = 0;
}
int main()
{
cin >> v;
for (int i = 0; i < v; i++)
{
cin >> p[i];
}
cin >> g;
for (int j = 0; j < g; j++)
{
for (int i = 0; i < v; i++)
{
cin >> a[j][i];
}
}
dfs(0);
cout << minP << " ";
for (int i = 0; i < g; i++)
{
if (ac[i] == 1)
{
cout << i + 1 << " ";
}
}
}
03-26
834