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 <algorithm>
#include <iostream>
long long xis[11];
long long lis[11];
long long pairs[11];
long long powstwo[11];
long long const prime=1000000007;
using namespace std;
int main()
{
int n;
cin >> n;
if (n<=10)
{
//code the brute force
for (int i=0; i<n; i++)
{
cin >> xis[i];
}
for (int i=0; i<n; i++)
{
cin >> lis[i];
pairs[i]=prime*lis[i]+xis[i];
}
sort(pairs, pairs+n);
for (int i=0; i<n; i++)
{
lis[i]=pairs[i]/prime;
xis[i]=pairs[i]%prime;
//cout << lis[i] << ' ' << xis[i] << '\n';
}
//what a terrible way to sort, if anyone reads this please comment on it
for (int i=0; i<n; i++)
{
powstwo[i]=(1<<(n-1-i));
}
int x=(1<<n)-1;
int maxbadge=0;
for (int i=0; i<=x; i++)
{
int y=i;
int level = 0;
int badge = 0;
for (int j=0; j<n; j++)
{
if (y>=powstwo[j])
{
y-=powstwo[j];
if (level<=lis[j])
{
level+=xis[j];
badge++;
}
}
}
maxbadge=max(badge, maxbadge);
}
cout << maxbadge << '\n';
}
else
{
cout << "IDK";
//assume all lis are equal
//do later
}
}
# | 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... |