# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
431536 | charterla | Jelly Flavours (IOI20_jelly) | C++14 | 125 ms | 472 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |