Submission #757936

#TimeUsernameProblemLanguageResultExecution timeMemory
757936BentoOreoGym Badges (NOI22_gymbadges)C++14
24 / 100
184 ms10480 KiB
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <deque>
#include <set>
#include <unordered_set>
#include <algorithm>
#define ll long long
using namespace std;
int max_count = 0;
unordered_map<int,pair<ll,ll> > copygarbage;
void recurse(unordered_map<int,pair<ll,ll> > gyms, ll level, int count){
    if(gyms.size() == 0){
        max_count = max(max_count,count);
    } else {
        for(auto elem: gyms){
            if(level <= elem.second.first){//if level less than level cap
                copygarbage = gyms;
                copygarbage.erase(elem.first);
                recurse(copygarbage, level + elem.second.second, count + 1);
            }
        }
        max_count = max(max_count,count);//if I exhaust all I still need to check lol
    }
}
int main(){
    //subtask 1 of problem 2 complete search dfs
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int len;
    ll hold;
    cin >> len;
    vector <ll> lvlgained,lvlcap;
    for(int i = 0; i < len; i++){
        cin >> hold;
        lvlgained.push_back(hold);
    }
    unordered_set <ll> temp;
    for(int i = 0; i < len; i++){
        cin >> hold;
        lvlcap.push_back(hold);
        temp.insert(hold);
    }if(temp.size() == 1){
        //1 unique value only
        sort(lvlgained.begin(),lvlgained.end());
        ll max_val = *temp.begin();
        ll total = 0;
        int count = 0;
        int j;
        for(int j = 0; j < lvlgained.size() && total <= max_val; j++){
            total += lvlgained.at(j);
            count++;
        }
        cout << count << endl;
    } else if (len >= 1 && len <= 10){
        unordered_map<int,pair<ll,ll> > gyms;
        for(int i = 0; i < len; i++){
            gyms[i] = {lvlcap.at(i),lvlgained.at(i)};
        }
        recurse(gyms,0,0);
        cout << max_count << endl;
    } else {
        cout << "WOOPS" << endl;
    }
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:54:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for(int j = 0; j < lvlgained.size() && total <= max_val; j++){
      |                        ~~^~~~~~~~~~~~~~~~~~
Main.cpp:53:13: warning: unused variable 'j' [-Wunused-variable]
   53 |         int j;
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...