Submission #757925

#TimeUsernameProblemLanguageResultExecution timeMemory
757925jer033Gym Badges (NOI22_gymbadges)C++17
0 / 100
1 ms212 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...