package main import . "fmt" func main() { var n int Scan(&n) a:=make([]int,n) b:=make([]int,n) for i:=range a { Scan(&a[i]) } for i:=range b { Scan(&b[i]) } dp:=make([]map[int]map[int]int,n+1) for i:=range dp { dp[i]=make(map[int]map[int]int) } dp[0][0]=map[int]int{0:1} for i,v:=range a { for k,m:=range dp[i] { for j,w:=range b { p:=1<w { s+=v-w } dp[i+1][k|p][s]+=c } } } } var ss,cc int for _,m:=range dp[n] { for s,c :=range m { if s>ss { ss=s cc=c } else if s==ss { cc+=c } } } Println(cc) }