Meaning:
There are n piles of dogs and n piles of cats. A takes a bunch of dogs and selects some dogs (at least one), B takes a bunch of cats and selects some cats (at least one). The one who chose the last animal won. Seeking whether the first player will win.
Idea: The
range of A selection times is [n, ∑ sum (a [i])] [n,∑sum(a[i])][n,∑s u m ( a [ i ] ) ] The
range of B selection times is[n, ∑ sum (b [i])] [n,∑sum(b[i])][n,∑s u m ( b [ i ] ) ]
takes only one best one at a time
, and whoever has the greater upper limit of the number of choices can win. If the upper limit of selection is the same, the second hand wins.
#include <cstdio>
using namespace std;
int main(){
int T;scanf("%d",&T);
while(T--){
int n;scanf("%d",&n);
int a = 0,b = 0;
for(int i = 1;i <= n;i++){
int x;scanf("%d",&x);
a += x;
}
for(int i = 1;i <= n;i++){
int x;scanf("%d",&x);
b += x;
}
if(a > b) printf("BaoBao\n");
else printf("DreamGrid\n");
}
return 0;
}