Submission #385539

#TimeUsernameProblemLanguageResultExecution timeMemory
385539The_BitchJelly Flavours (IOI20_jelly)C++14
35 / 100
1784 ms579452 KiB
//#define int long long #include "jelly.h" #include <bits/stdc++.h> #define pb push_back #define F first #define S second using namespace std; const int N=1e6,M=1e4; int mem[203][600][600]; long long minn=1e18,mux=-1e18; int n,x,y; vector<int> a,b; int dp(int i,int x,int y){ if(i==n)return 0; if(mem[i][x][y]!=-1) return mem[i][x][y]; if(x>=a[i]&&y>=b[i]) return mem[i][x][y]=max({dp(i+1,x-a[i],y)+1,dp(i+1,x,y-b[i])+1,dp(i+1,x,y)}); else if(x>=a[i]&&y<b[i]) return mem[i][x][y]=max(dp(i+1,x-a[i],y)+1,dp(i+1,x,y)); else if(x<a[i]&&y>=b[i]) return mem[i][x][y]=max(dp(i+1,x,y-b[i])+1,dp(i+1,x,y)); else return mem[i][x][y]=dp(i+1,x,y); } int find_maximum_unique(int x, int y, std::vector<int> a2, std::vector<int> b2) { n = a2.size(); a = a2,b = b2; for(int i=0;i<n+2;i++) for(int j=0;j<x+2;j++) for(int k=0;k<y+2;k++) mem[i][j][k]=-1; return dp(0,x,y); } vector<int>a1,b1; /* int main() { assert(scanf("%d %d %d", &n, &x, &y) == 3); a1.resize(n); b1.resize(n); for (int i = 0; i < n; i++) { assert(scanf("%d %d", &a1[i], &b1[i]) == 2); } fclose(stdin); int answer = find_maximum_unique(x, y, a1, b1); printf("%d\n", answer); } */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...