Submission #431536

#TimeUsernameProblemLanguageResultExecution timeMemory
431536charterlaJelly Flavours (IOI20_jelly)C++14
100 / 100
125 ms472 KiB
#include "jelly.h" #include <iostream> #include <algorithm> #include <vector> using namespace std; vector<int> A,B; int tag[2005]; bool cmp(int a,int b){ return A[a]<A[b]; } int find_maximum_unique(int x, int y, vector<int> a, vector<int> b){ A=a;B=b; for(int i=0;i<A.size();i++)tag[i]=i; sort(tag,tag+A.size(),cmp); //for(int i=0;i<A.size();i++)cout<<i<<":<"<<tag[i]<<">->"<<A[tag[i]]<<" ";cout<<endl; int f[10005][2],ans=0; for(int j=0;j<=y;j++){f[j][0]=0;f[j][1]=x;} for(int k=0;k<a.size();k++){ for(int j=y;j>=0;j--){ if(a[tag[k]]==0 || b[tag[k]]==0){ f[j][0]+=1; ans=max(ans,f[j][0]); continue; } if(f[j][1]>=a[tag[k]]){ f[j][0]=f[j][0]+1; f[j][1]-=a[tag[k]]; } if(j>=b[tag[k]]){ if((f[j-b[tag[k]]][0]+1==f[j][0] && f[j-b[tag[k]]][1]>f[j][1]) || (f[j-b[tag[k]]][0]+1>f[j][0])){ f[j][0]=f[j-b[tag[k]]][0]+1; f[j][1]=f[j-b[tag[k]]][1]; } } ans=max(ans,f[j][0]); } //cout<<a[tag[k]]<<","<<b[tag[k]]<<": ";for(int j=0;j<=y;j++)cout<<f[j][0]<<","<<f[j][1]<<" ";cout<<endl; } return ans; }

Compilation message (stderr)

jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i=0;i<A.size();i++)tag[i]=i;
      |              ~^~~~~~~~~
jelly.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int k=0;k<a.size();k++){
      |              ~^~~~~~~~~
#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...