{"problem":{"name":"Max Sum Counting","description":{"content":"Given are sequences of $N$ integers each: $A = (A_1, \\dots, A_N)$ and $B = (B_1, \\dots, B_N)$. Find the number of non-empty subsets $S$ of ${1,2,\\ldots,N}$ that satisfy the following condition: *   $","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc216_f"},"statements":[{"statement_type":"Markdown","content":"Given are sequences of $N$ integers each: $A = (A_1, \\dots, A_N)$ and $B = (B_1, \\dots, B_N)$. Find the number of non-empty subsets $S$ of ${1,2,\\ldots,N}$ that satisfy the following condition:\n\n*   $\\max_{i \\in S} A_i \\geq \\sum_{i \\in S} B_i$.\n\nSince the count can be enormous, print it modulo $998244353$.\n\n## Constraints\n\n*   $1 \\leq N \\leq 5000$\n*   $1 \\leq A_i,B_i \\leq 5000$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\ldots$ $A_N$\n$B_1$ $B_2$ $\\ldots$ $B_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc216_f","tags":[],"sample_group":[["2\n3 1\n1 2","2\n\n${1,2,\\ldots,N}$ has three subsets: ${1}$, ${2}$, and ${1,2}$.\n\n*   For $S={1}$, we have $\\max_{i \\in S} A_i=3$ and $\\sum_{i \\in S} B_i=1$.\n*   For $S={2}$, we have $\\max_{i \\in S} A_i=1$ and $\\sum_{i \\in S} B_i=2$.\n*   For $S={1,2}$, we have $\\max_{i \\in S} A_i=3$ and $\\sum_{i \\in S} B_i=3$.\n\nThus, the condition $\\max_{i \\in S} A_i \\geq \\sum_{i \\in S} B_i$ is satisfied by two subsets: ${1}$ and ${1,2}$."],["2\n1 1\n2 2","0\n\nThere may be no subsets that satisfy the condition."],["20\n1937 3980 2689 1208 3640 1979 581 2271 4229 3948 3708 1522 4161 4661 3797 96 3388 3395 2920 2247\n4485 2580 174 1156 3770 3396 3558 3500 3494 479 269 3383 1230 1711 3545 3919 134 475 3796 1017","476"]],"created_at":"2026-03-03 11:01:14"}}