Submission #423574

#TimeUsernameProblemLanguageResultExecution timeMemory
423574victoriadJelly Flavours (IOI20_jelly)C++14
11 / 100
2108 ms2097156 KiB
#include "jelly.h" #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <utility> #include <queue> #include <map> #include <iomanip> #include <stack> #include <fstream> using namespace std; vector<vector<vector<int> > >dp; int maxi(int x, int y, std::vector<int> a, std::vector<int> b,int nodo){ if(nodo==a.size()||(x==0 && y==0))return 0; int &ans=dp[nodo][x][y]; if(ans !=-1)return ans; if(a[nodo]<=x && b[nodo]<=y){ return dp[nodo][x][y]=max(maxi(x,y,a,b,nodo+1),max(maxi(x-a[nodo],y,a,b,nodo+1)+1,maxi(x,y-b[nodo],a,b,nodo+1)+1)); } else if(a[nodo]<=x){ return dp[nodo][x][y]=max(maxi(x,y,a,b,nodo+1),maxi(x-a[nodo],y,a,b,nodo+1)+1); } else if(b[nodo]<=y){ return dp[nodo][x][y]=max(maxi(x,y,a,b,nodo+1),maxi(x,y-b[nodo],a,b,nodo+1)+1); } else{ return dp[nodo][x][y]=maxi(x,y,a,b,nodo+1); } } int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) { int n = a.size(); if(y!=0){ vector<int>j(y+x,-1); vector<vector<int> > g; for(int i=0;i<x+y;i++)g.push_back(j); for(int i=0;i<n;i++)dp.push_back(g); return maxi(x,y,a,b,0); } else{ sort(a.begin(),a.end()); int m=0; for(int i=0;i<n;i++){ if(a[i]<=x){ m++; x-=a[i]; } else{ break; } } return m; } }

Compilation message (stderr)

jelly.cpp: In function 'int maxi(int, int, std::vector<int>, std::vector<int>, int)':
jelly.cpp:16:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  if(nodo==a.size()||(x==0 && y==0))return 0;
      |     ~~~~^~~~~~~~~~
#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...