id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "int zz = 0;\nclass Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) \n {\n long long dp[4];\n dp[0]=dp[1]=dp[2]=dp[3]=-1e18;\n dp[0] = a[0] *1ll* b[0];\n \n int n = (int)b.size(), i = 1;\n while(i < n)\n {\n for (int ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n long long dp[4][100004];\n\n long long solve(int a_ind , int b_ind,vector<int>& a, vector<int>& b ){\n if(a_ind >= a.size()) return 0;\n if(b_ind >= b.size()) return -1e9;\n\n if(dp[a_ind][b_ind] != -1) return dp[a_ind][b_ind];\n\n long long int... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n long long dp[n][4];\n memset(dp, -1, sizeof(dp));\n auto dfs = [&](auto&& dfs, int i, int j) -> long long {\n if (j == 4) return 0;\n if (i >= n) retur... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n \n long long t[4][100005];\n \n long long Solve(vector<int>&A, vector<int>&B, int i, int j){\n if(i==A.size()) return 0;\n if(j==B.size()) return -1e15;\n \n if(t[i][j]!=-1)\n return t[i][j];\n \n long long Ans = ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n long long dp[4][100005];\n long long f(vector<int>& a, vector<int>& b, int i, int j) {\n if(i < 0) return 0;\n if(j < 0) return -1e13;\n if(dp[i][j] != -1) return dp[i][j];\n return dp[i][j] = max(a[i] * 1LL * b[j] + f(a, b, i-1, j-1), f(a, b, i... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n long long dp[4][100001];\n long long rec(int i,int j,vector<int>&a,vector<int>&b,int m,int n){\n if(i==m)return 0;\n if(i>m||j>=n)return INT_MIN;\n if(dp[i][j]!=-1)return dp[i][j];\n long long maxi=LONG_MIN;\n maxi=max(maxi,rec(i,j+1,a,b,... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n long long dp[4][100001];\n long long rec(int i,int j,vector<int>&a,vector<int>&b,int m,int n){\n if(i==m)return 0;\n if(i>m||j>=n)return INT_MIN;\n if(dp[i][j]!=-1)return dp[i][j];\n long long maxi=LONG_MIN;\n maxi=max(maxi,rec(i,j+1,a,b,... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "long long dp[4][100010];\nclass Solution {\npublic:\n int n;\n vector<int> a,b;\n long long dfs(int i, int j) {\n if (j == n) {\n return i == 4 ? 0 : -1000000000000;\n }\n if (i == 4) {\n return 0;\n }\n if (dp[i][j] != -1) return dp[i][j];\... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long int dp[100010][5];\n int done[100010][5];\n\n long long int rec(int level, int cnt, vector <int> &a, vector <int> &b){\n if(cnt == 4)return 0;\n else if(level == b.size() && cnt != 4)return -1e13;\n\n if(done[level][cnt] != 0)return dp[lev... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n vector<long long> curr(b.size()+1);\n vector<long long> next(curr);\n int n = b.size();\n for (int i = 3; i >= 0; --i) {\n curr[n-3+i] = LLONG_MIN;\n for (int j = n - 4 + ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n int size = b.size();\n vector<long long> choose_a(size, 0), choose_b(size, 0);\n\n choose_a[size - 1] = (long long)b[size - 1] * a[3];\n for(int i = size - 2; i > -1; i--) choose_a[i] = max(cho... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "using ll = long long;\n\nll alg[5][100'005];\nbool visited[5][100'005];\n\nclass Solution {\npublic:\n vector<int> a;\n vector<int> b;\n \n ll Dfs(int a_i, int b_i) {\n if (visited[a_i][b_i]) {\n return alg[a_i][b_i];\n }\n if (a_i == 4) {\n visited[a_i][b_i] = true;\n alg[a_i][... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long INF = 1e16;\n long long cache[7][100005];\n long long dp(int i, int j, vector<int>& a, vector<int>& b) {\n if(i >= 4) {\n return 0;\n }\n if(j >= (int)b.size()) {\n return -INF;\n }\n if(cache[i][j] != -... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = 4, m = b.size() ;\n vector<long long>dp(m+1, 0) ;\n \n for(int i=n-1 ; i>=0 ; i--)\n {\n long long prev1 = -1e15, prev2 = -1e15 ;\n\n for(int j=m-1 ; j>=0 ; j--... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n vector<long long> dp(b.size() - 2, 0);\n // vector<long long> next(b.size() - 2, LLONG_MIN);\n\n // [ 3, 2, 5, 6 ]\n // [ 2, -6, 4, -5, -3,2,-7]\n\n // 0 0 0 ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "#define ll long long\nclass Solution {\npublic:\n long long int dp[4][100005];\n const long long INF = -1e17;\n long long dfs(int i, int j, vector<int>& a, vector<int>& b)\n {\n if(i == a.size()) return 0;\n if(j == b.size()) return INF;\n if(dp[i][j] != -1) return dp[i][j]... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n #define ll long long\n ll dp[4][100005];\n ll f(int index1,int index2,vector<int> &a,vector<int> &b){\n if(index1 >= a.size()){\n return 0;\n }\n if(index2 >= b.size()){\n if(index1 < a.size()){\n return -1e11;\n... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "using namespace std;\n\ntypedef long long ll;\n#define MIN -90909090909\n\nclass Solution {\npublic:\n\n ll score[4][100000];\n\n long long calcScore(vector<int>&a, vector<int>&b, int ai, int bi) {\n if (ai >= a.size()) return 0;\n if (bi >= b.size()) return -40404040404;\n if (s... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n\tlong long dp[4][100001];\n\tint n;\n\t\n\tlong long solve(int i,int j,vector<int>& a, vector<int>& b){\n\t\tif(i==4)\n\t\t\treturn 0;\n\t\tif(j==n)\n\t\t\treturn -1000000000000;\n\t\tif(dp[i][j]!=-1)\n\t\t\treturn dp[i][j];\n\t\tlong long ans = solve(i+1,j+1,a,b) + (long long)a... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long dp[100001][4];\n long long hp(int i,int j,vector<int>& a,vector<int>& b){\n if(i==4)return 0;\n if(j==b.size())return LONG_LONG_MIN;\n if(dp[j][i]!=-1)return dp[j][i];\n long long ans=hp(i,j+1,a,b);\n long long tp=hp(i+1,j+1,a,b... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\n #define ll long long\n ll mem[4][100002];\n ll maxVal(vector<int>& a,int pos_a,vector<int>& b,int pos_b){\n if(pos_a==4) return 0;\n if(mem[pos_a][pos_b]!=-1)\n return mem[pos_a][pos_b];\n \n //Don't multiply current pos_b with pos_a\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "typedef long long ll;\n\nll SUM_LESS_THAN_MIN = -1e10*4-1;\nclass Solution {\npublic:\n ll maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n vector<vector<ll>> dp(2, vector<ll>(n + 1, SUM_LESS_THAN_MIN));\n for (int j = n - 1; j >= 3; j -= 1)\n dp[1][j] = m... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "typedef long long ll;\n\nll SUM_LESS_THAN_MIN = -1e10 * 4 - 1;\n\nclass Solution {\npublic:\n ll maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n vector<vector<ll>> dp(2, vector<ll>(n + 1));\n for (int i = 3; i >= 0; i -= 1) {\n int endJ = n + i - 4, k = i... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\nlong long dp[5][100100];\nvector<int>a,b;\nint n;\nlong long f(int i,int j){\n if(i==4) return 0;\n if(j>=n) return -1e18;\n if(dp[i][j]!=-1) return dp[i][j];\n long long t=(long long)a[i]*(long long)b[j]+f(i+1,j+1);\n long long t1=f(i,j+1);\n return dp[i][j]=ma... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "#include <vector>\n#include <cstring>\n#include <algorithm>\n\nusing namespace std;\n\nclass Solution {\npublic:\n vector<int> A, B;\n long long dp[100001][5];\n int n, m;\n\n long long rec(int i, int state) {\n if (i == m) {\n if (state == 4) {\n return 0;\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\n int n, m;\n long long dp[4][(int)(5*1e5)];\n long long solve(int i, int j, vector<int>& a, vector<int>& b) {\n // BaseCase\n if(i == n) return 0;\n if(j >= m) return LLONG_MIN;\n if(dp[i][j] != -1) return dp[i][j];\n\n long long notTake = solve... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\n vector<int>a,b;\n int k;\n long long dp[100001][5];\n long long f(int i,int c){\n int n=b.size();\n if(dp[i][c]!=-1)return dp[i][c];\n\n if(c==4){\n return 0;\n }\n if(i==n){\n return -1e16;\n }\n \n lon... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long dp[5][5][100010];\n long long maxm(vector<int> &a, vector<int> &b, int pos1,int pos2,int cnt) {\n int n = b.size();\n if(pos1 >= 4) return 0;\n if(pos2 >= n) {\n return INT_MIN;\n }\n if(dp[pos1][cnt][pos2] != -1) ret... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n int n;\n long long dp[100010][5];\n int done[100010][5];\n vector<int> a,b;\n long long rec(int id, int pos){\n if (pos>=4)return 0;\n if (id>=n)return -1e15;\n if (done[id][pos])return dp[id][pos];\n long long ans = -1e15;\n ans... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long dp[5][100000];\n long long solve(int i, int j, vector<long long>& a, vector<long long>& b){\n int n = a.size(), m = b.size();\n if(i >= n)\n return 0;\n\n if(j >= m)\n return -4*1e10;\n\n if(dp[i][j] != -1)\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long dp[5][500001];\n long long maxScore(vector<int>& a, vector<int>& b) {\n memset(dp, -1, sizeof(dp));\n return solve(a, b, 0, 0);\n }\n\n long long solve(vector<int>& a, vector<int>& b, int i, int j) {\n if (i >= a.size()) {\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\n const int M = 4;\n const long long LINF = 1LL << 62;\n \n using ll = long long;\n using vl = vector<ll>;\n using vvl = vector<vl>;\n \npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n \n vvl dp(2, vl(n + 1, 0));\n int cur = 0, nxt =... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n \n long long out = std::numeric_limits<long long>::min();\n\n long long max_1 = std::numeric_limits<long long>::min();\n std::vector<long long> l_maxes(b.size(), std::numeric_limits<long long>:... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long cms(vector<int> multipliers, vector<int> values) {\n int size = values.size();\n\n \n vector<long long int > dpOne(size, LLONG_MIN);\n vector<long long int > dpTwo(size, LLONG_MIN);\n vector<long long int > dpThree(size, LLONG_MIN);\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "#include <iostream>\n#include <vector>\n#include <queue>\n#include <algorithm>\n#include <climits>\n\nusing namespace std;\n\nclass Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n int n = b.size();\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long dp[100001][5][5];\n long long f(int i,int j, int tot, vector<int>& a, vector<int>& b)\n {\n if(j>=b.size())\n {\n if(tot==4)\n return 0;\n else\n return -1e18;\n }\n \n if(i... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n #define ll long long\n ll dp[100001][5][5];\n ll solve(int i, int j, vector<int> &b, vector<int> &a, int k)\n {\n if(k == 0) return 0;\n if(b.size() == i) return -1e18;\n \n if(dp[i][j][k] != -1) return dp[i][j][k];\n ll ans = -1e18;\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n vector<array<long long, 5>> f(n + 1);\n for (int j = 1; j < 5; j++) {\n f[0][j] = LLONG_MIN / 2;\n }\n for (int i = 0; i < n; i++) {\n for (int ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "#include <vector>\n#include <algorithm>\n#include <climits> // For LLONG_MIN\n\nclass Solution {\npublic:\n long long maxScore(std::vector<int>& a, std::vector<int>& b) {\n int n = a.size();\n int m = b.size();\n\n if (n > m || n == 0) return 0;\n\n vector<vector<long long>>... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "#define ll long long\nclass Solution {\npublic:\n ll dp[5][100005][5];\n ll fun(vector<int>& a, vector<int>& b, int i, int j, int k){\n if(k==0) return 0;\n if(i>=4) return 0;\n if(j>=b.size()) return -1e12;\n\n if(dp[i][j][k]!=-1) return dp[i][j][k];\n\n ll ans=-1e... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<long long>> dp;\n vector<vector<bool>> found;\n int n;\n long long score(vector<int>& a, vector<int>& b, int i, int j){ \n if(i==4) return 0;\n if(j==n) return LLONG_MIN;\n if(found[i][j]) return dp[i][j];\n\n found[i]... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n vector<array<long long,4>> memo;\n long long dp(vector<int>& a, vector<int>& b,int idx,int len) {\n if(idx==b.size()||len==4)\n return 0;\n if(memo[idx][len]!=LLONG_MIN)\n return memo[idx][len];\n long long result=LLONG_MIN;\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\n long long mx = -1 * 40000000000;\n long long store[4][100001];\n long long dp(vector<long long>&a,vector<long long>&b,int i,int j){\n if(i < 0) return 0;\n if(j < 0) return mx;\n if(store[i][j] != mx) return store[i][j];\n long long ans = mx;\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n using ll=long long;\n ll dp[100001][4][5];\n vector<ll>a,b;\n ll f(int ind ,int ind2, int cnt){\n if(ind2<0){\n if(cnt==0)return 0;\n return -1e15;}\n if(ind<0)return -1e15;\n if(dp[ind][ind2][cnt]!=-1)return dp[ind][ind2][c... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "\n\nclass Solution {\n long long f(vector<long long>& a, vector<long long>& b, int i, int j){\n if(i==a.size()) return 0 ;\n if(j==b.size()) return -100e9 ;\n \n if(dp[i][j] != -1) return dp[i][j] ;\n \n long long pick = (long long)(a[i] * b[j]) + f(a,b,i+1,j+1... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n vector<vector<long long>> dp( 4, vector<long long>(n,INT_MIN) );\n for( int i = 3 ; i < n ; i++ ) dp[3][i] = (long long)a[3]*b[i];\n\n deque<int> q;\n q.push_back(3);... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\n vector<vector<long long> > dp;\n long long solve(int i, int j, vector<int>& a, vector<int>& b) {\n if(i >= 4) {\n return 0;\n }\n if(j >= b.size()){\n return -1e12;\n }\n auto &ans = dp[i][j];\n if(ans != -1)\n retur... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "class Solution {\npublic:\n\nlong long min(long long int a,long long int b){ if(a<b) return a; else return b;}\nlong long int max(long long int a,long long int b){ if(a>b) return a; else return b;}\n \n long long maxScore(vector<int>& a, vector<int>& b) {\n int n=a.size(),m=b.size() ;\n vec... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 1 | {
"code": "typedef long long ll;\nclass Solution {\n ll f(int i, int j, vector<int>& a, vector<int>& b, int n, vector<vector<ll>>& dp){\n if(i==4) return 0;\n if(j==n) return -1e9;\n if(dp[i][j]!=-1) return dp[i][j];\n \n ll pick=(ll)(a[i])*(ll)(b[j])+f(i+1, j+1, a, b, n, dp);\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "#define ll long long\n\nclass Solution {\n vector<vector<ll>> dp;\n ll solve(int i ,int j , vector<int> & a ,vector<int> &b) {\n if(i >= 4) return 0;\n if(j >= b.size()) return -1e10;\n if(dp[i][j] != -1e18) return dp[i][j];\n return dp[i][j] = max(1ll*a[i] * b[j] + solve(i+1,j+1,a,b) ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n vector<vector<long long>> dp(a.size(),vector<long long>(b.size()+1,INT_MIN));\n dp.push_back(vector<long long>(b.size()+1,0));\n dp[a.size()-1][b.size()-1] = (long long)a.back() * b.back();\n\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\npublic:\n#define ll long long\n int n, m;\n ll dp[5][1000005];\n\n long long solve(int i, int j, vector<int>& a, vector<int>& b) {\n if (i >= 4) {\n // We have used exactly n elements from a\n return 0;\n }\n if(j>=m){\n retur... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\npublic:\n \n int fun(int n){\n unordered_map<int,int> mpp;\n for(int i=0;i<n;i++){\n mpp[n]++;\n }\n return 0;\n }\n \n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n fun(n);\n fun(n);\... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\npublic:\nlong long helper(vector<int> &a, vector<int>& b,int i1,int i2,vector<vector<long long int>>& v){\n if(i1==a.size()) return 0;\n if(i2>=b.size()) return -1e9;\n if(v[i1][i2]!=-1) return v[i1][i2];\n\n long long int take=(long long)a[i1]*(long long)b[i2]+ helper(a,b,i1+... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\n long long dp[4][100002];\n long long solve( int m,int n, vector<int>& a, vector<int>& b){\n if( m == 0) return 0;\n if( dp[m-1][n-1]!=-1) return dp[m-1][n-1];\n if( m<n){\n return dp[m-1][n-1] = max( a[m-1]*1LL*b[n-1] + solve( m-1,n-1, a, b) , solve... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\npublic:\n #define lli long long int\n long long maxScore(vector<int>& aa, vector<int>& bb) {\n \n \n// sort(b.begin(), b.end());\n// vector<int> pos, neg;\n \n// for(auto i: v)\n// {\n// if(i>=0)\n// po... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "// class Solution {\n// public:\n// // long long fun(int i,int j,vector<int> &a,vector<int> &b,vector<long long<vector<long long>> &dp){\n// // if(i==3 && j<=1) return LLONG_MIN;\n// // if(i>=2 && j<=2) return LLONG_MIN;\n// // if(i>=1 && j<=3) return LLONG_MIN;\n// // i... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n // vector<long long> a(begin(a1), end(a1));\n // vector<long long> b(begin(b1), end(b1));\n int n= b.size();\n vector<vector<long long>> f(4,vector<long long>(b.size(),0));\n for (int j=... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n vector<vector<long long>> dp(4,vector<long long>(b.size(),LONG_LONG_MIN));\n for(int i=0;i<4;i++){\n for(int j=i;j<b.size();j++){\n if(i==0 and j==0)\n dp[i][j] =... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\n public:\n long long maxScore(vector<int>& a, vector<int>& b) {\n const int kN = b.size();\n vector<vector<long long>> dp(4, vector<long long>(kN, LLONG_MIN));\n function<long long(int, int)> recur = [&] (int pos, int i) {\n if (pos == 4) {\n return 0LL;\n }\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "#define ll long long\n\nclass Solution {\npublic:\n vector<vector<ll>> dp;\n int m, n;\n \n ll recur(int i, int j, vector<int>& a, vector<int>& b) {\n if (i >= 4) return 0;\n if (j >= n) return -1e15;\n \n ll &d = dp[i][j];\n if (d != -1) return d;\n \n... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\n\n vector<long long> prodUtil(vector<int>& b, int x, vector<long long> prv)\n {\n int n=b.size();\n vector<long long> curr(n,-1e15);\n for(int i=1;i<n;i++)\n {\n curr[i]=max(curr[i-1],prv[i-1]+x*1LL*b[i]);\n }\n return curr;\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "#include <vector>\n#include <algorithm>\n#include <limits>\n\nclass Solution {\npublic:\n long long maxScore(std::vector<int>& a, std::vector<int>& b) {\n int n = b.size();\n \n // Initialize DP arrays and prefix maximum arrays\n std::vector<long long> dp1(n, std::numeric_lim... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\n int len;\n int* containerA;\n int* containerB;\n long long DEFAULT;\n long long INVALID;\n long long** cache;\n\n long long dfs(int aIndex, int bIndex) {\n if (bIndex == len || aIndex == 4) {\n return aIndex == 4 ? 0 : INVALID;\n }\n\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<long long>> memo;\n\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n // Initialize the memoization table with -1\n memo.resize(5, vector<long long>(n, -1));\n // Start the recursive function\n re... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\npublic:\n long long solve(const vector<int>& a, const vector<int>& b, int i1, int i2, vector<vector<long long>>& dp) {\n if (i1 >= a.size() || i2 >= b.size()) {\n return i1 >= a.size() ? 0 : -1e10;\n }\n if (dp[i1][i2] != -1) {\n return dp[i1]... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\npublic:\n long long solve(vector<int>& a, vector<int>& b,int i1,int i2,vector<vector<long long >> &dp){\n if(i1>=a.size() || i2>=b.size()){\n if(i1>=a.size()){\n return 0;\n }\n return -1e8;\n }\n if(dp[i1][i2]!=-1){\... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\npublic:\n vector<int> num1;\n vector<int> num2;\n int n;\n vector<vector<long long>> dp;\n\n // Recursive function to compute the maximum score using \"pick\" or \"non-pick\" strategy\n long long solve(int i, int j) { \n if (i == 4) return 0; // Base case: when w... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\npublic:\n\n long long func (int in , int left , vector<int>& a , vector<int>& b , vector<vector< long long>>& dp){\n if (left == 0){\n return 0;\n }\n int n = b.size();\n if (in >= n){\n return INT_MIN;\n }\n if (dp[left][... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution \n{\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) \n {\n int m = a.size(), n = b.size();\n a.insert(a.begin(), -1);\n b.insert(b.begin(), -1);\n\n std::vector<std::vector<long long>> dp(m + 1, std::vector<long long>(n + 1, LONG_LONG_MIN / 2))... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 2 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n vector<vector<long long>> dp(5, vector<long long>(1+n,-99999999999999));\n for (int i =0;i<=n;i++) \n dp[4][i] = 0;\n for (int i = 3;i>=0;i--) {\n for ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n long long f(vector<int> a,vector<int> b,int i,int j,vector<vector<long long int>> &dp){\n if(i==a.size()) return 0;\n if(j>=b.size()) return -1e9;\n if(dp[i][j]!=-1) return dp[i][j];\n long long int take=(long long)a[i]*(long long)b[j]+f(a,b,i+1,j+... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "auto init = []() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n return 'c';\n}();\nclass Solution {\npublic:\n long long check(vector<int> &a,vector<int> &b, int i,int j,vector<vector<long long int>> &dp){\n if(i==4){\n return 0;\n }\n if(j>=b.siz... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n long long solve(vector<int>& a, vector<int>& b, int i, int j, vector<vector<long long>>& dp) {\n if(i==4) return 0;\n if(j>=b.size()) return 4*(-1e10);\n if(dp[i][j] != -1) return dp[i][j];\n long long take = (long long)a[i]*(long long)b[j] + s... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n long long f(int ind1,int ind2,int n,vector<int>& a, vector<int>& b,vector<vector<long long>>&dp) \n {\n if(ind1==4)\n {\n return 0ll;\n }\n\n if(ind2==n)\n {\n return -1e15-5;\n }\n\n long long &x=dp[in... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n#define ll long long \n \n\n ll h(int i, int j, vector<int>&a,vector<int>&b,vector<vector<ll>>&dp){\n\n if(i==-1) return 0;\n if(j==-1) return LLONG_MIN;\n\n if(dp[i][j]!=-2) return dp[i][j];\n\n ll notTake = h(i,j-1,a,b,dp);\n ll v = h(i-... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n \n long long solve(vector<int> &a, vector<int> &b,int i ,int j, vector<vector<long long>> &dp)\n{\n if(i>=a.size())\n {\n return 0;\n } \n\n if(j>=b.size())\n {\n return -10e9;\n }\n \n if(dp[i][j]!=-1)\n {\n return dp[i][j];\n }\n long long int... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n long long mini=(long long) -(4e10 + 1);\n vector<vector<long long>> dp;\n long long solve(vector<int>& a, vector<int>& b, int i, int j){\n if(i<0) return 0;\n else if(j<0) return mini;\n else if(dp[i][j]!=-1) return dp[i][j];\n else if(a[i]==... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "#define ll long long \nclass Solution {\npublic:\n ll maxScore(vector<int>& a_, vector<int>& b_) {\n vector<ll> a;\n for (int i : a_) a.push_back(i);\n vector<ll> b;\n for (int i : b_) b.push_back(i);\n //\n int n = b.size();\n //\n vector<ll> left... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\n#define dbg(...) __f(#__VA_ARGS__,__VA_ARGS__)\n// trace std::pair\ntemplate<class L,class R> std::ostream& operator<<(std::ostream& os,std::pair<L,R>& P){\n return os<<\"{\"<<P.first<<\":\"<<P.second<<\"}\";\n}\n// trace std::vector\ntemplate<class T> std... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\n #define ll long long\npublic:\n long long solve(vector<int>& a, vector<int>& b,int i1,int i2,vector<vector<ll>>& dp){\n if(4-i1 > b.size()-i2) return -1e12;\n if(i1==4 && i2<3) return -1e12;\n if(i1==4 || i2==b.size()) return 0;\n \n if(dp[i1][i2]... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "static const int __ = []() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); return 0; }();\n\ntypedef long long ll; typedef unsigned int ui; typedef unsigned long long ull; typedef pair<int ,int> pii; typedef pair<ll, ll> pll; typedef double rl;\ntypedef pii int2; typedef ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n #define ll long long\n ll solve(ll i, ll j,vector<ll> &a, vector<ll> &b,vector<vector<ll>> &dp)\n {\n if(i==4)\n return 0;\n if(j==b.size())\n return -1e16;\n if(dp[i][j] != LLONG_MIN)\n return dp[i][j];\n \n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n int n;\n vector<vector<long long>> dp;\n long long solve(vector<int>& a, vector<int>& b, int i, int j) {\n if(i >= 4)\n return 0;\n if(j >= n)\n return -1e12;\n if(dp[i][j] != LLONG_MIN)\n return dp[i][j];\n\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<long long>> dp;\n long long solve(vector<int> &a, vector<int> &b, int i1, int i2)\n {\n if(i1 >= a.size()) return 0;\n if(i2 >=b.size()) return (long long) -1e18;\n if(dp[i1][i2]!=-1) return dp[i1][i2];\n long long take = (long ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\n int n;\npublic:\n long long solve(vector<int>& a, vector<int>& b,int i,int j,vector<vector<long long>>&dp){\n if(i>=4){\n return 0;\n }\n if(j>=n){\n if(i>=4){\n return 0;\n }\n long long ans=(long lon... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n \n \n long long solve(int i , int j, vector<int>& a, vector<int>& b , vector<vector<long long>> &dp) {\n if(i>=4) return 0;\n if(j>=b.size()) return LONG_MIN;\n \n if(dp[i][j] != -1) return dp[i][j];\n \n long lon... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n long long solve(vector<vector<long long>>&dp,vector<int>&a,vector<int>&b,int i,int j,int n){\n if(j>n)return -1e18;\n if(i>=4){\n return 0;\n }\n if(dp[i][j]!=-1e18)return dp[i][j];\n long long l=-1e18,r=-1e18;\n if(j<n)l=1... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n typedef long long ll;\n ll solveRec(vector<int>& a, vector<int>& b, int i, int j){\n if(i==4) return 0;\n if(j==b.size()) return INT_MIN;\n ll res = 0;\n ll op1 = res + a[i]*b[j] + solveRec(a,b,i+1,j+1);\n ll op2 = res + solveRec(a,b,i,j+... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\n long long solve(int iFromA, int iFromB, vector<int>& a, vector<int>& b, vector<vector<long long int>> &dp){\n if (iFromA == a.size()){\n return 0;\n }\n if(dp[iFromA][iFromB]!=-1)return dp[iFromA][iFromB];\n \n long long int s1 = (long long)a[... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n \n long long returnMaxScore(vector<int>& a,vector<int>&b,int idx1,int idx2,int n,int m,vector<vector<long long>>& dp){\n\n if(idx1 == n)return 0;\n \n if(idx2 == m)return LLONG_MIN;\n \n if(dp[idx1][idx2] != -1)return dp[idx1][idx2];\n \n \... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n long long solve(int x, int y, vector<long long> &a, vector<long long> &b, vector<vector<long long>> &dp)\n {\n if(dp[x][y]!=-1e18)\n return dp[x][y];\n int n=a.size();\n int m=b.size();\n if(x==n && y==m)\n return 0;\n else ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\n\nvector<vector<long long> > dp;\n\nlong long solve(vector<int>& a, vector<int>& b, int i, int j, int n){\n // base case\n if(i==4) return 0;\n if(j==n) return LLONG_MIN;\n\n if(dp[i][j]!=LLONG_MIN) return dp[i][j];\n \n //recursion\n long long take = solve(a, b, i+1,... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int> &a, vector<int> &b) {\n vector<long long> dp1 = {1ll * a[0] * b[0]};\n vector<long long> dp2 = {0, 1ll * a[0] * b[0] + 1ll * a[1] * b[1]};\n vector<long long> dp3 = {0, 0, 1ll * a[0] * b[0] + 1ll * a[1] * b[1] + 1ll * a[2] ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n long long solve(vector<int>& a,vector<int>& b,int i,int j,vector<vector<long long>>& dp){\n if(j >= b.size()){\n if(i >= a.size())\n return 0;\n return -1e12;\n }\n \n if(i >= 4){\n return 0;\n }... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n long long solve(vector<long long>& a, vector<long long>& b,int i,int j,vector<vector<long long>> &dp)\n {\n if(i==a.size())\n return 0;\n\n if(j==b.size())\n return LLONG_MIN;\n \n if(dp[i][j]!=-1)\n return dp[i][j];\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\npublic:\n long long fun(int i, int j, vector<long long>& a, vector<long long>& b, vector<vector<long long>> &dp)\n {\n if(i == 4) return 0;\n if(j == b.size()) return -1*1e12;\n if(dp[i][j] != -1) return dp[i][j];\n\n long long t = 1LL*a[i]*b[j] + fun(i+... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\n #define ll long long\n\npublic:\n vector<vector<ll>>dp;\n int n;\n ll helper(int idx,int s,vector<int>& a,vector<int>& b)\n {\n if(s==4)return 0;\n if(idx==n)return -1e9; // possiblity as 4 numbers not selected\n if(dp[idx][s]!=-1)return dp[idx][s];\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\n #define ll long long\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n long long out = 0;\n vector<long long> dp(5,-100000000000);\n dp[0] = 0;\n for(int i = 0; i < b.size(); ++i){\n long long cc = b[i];\n vector<lon... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 3 | {
"code": "class Solution {\n #define ll long long\n vector<vector<ll>>dp;\n int n;\n ll f(int idx,int g,vector<int>& a, vector<int>& b){\n if(g==4)return 0;\n if(idx==n)return -1e12;\n if(dp[idx][g]!=-1e12)return dp[idx][g];\n ll ans1=f(idx+1,g,a,b);\n ll ans2=f(idx+1,g... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.