답안 #757936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757936 2023-06-14T02:14:17 Z BentoOreo Gym Badges (NOI22_gymbadges) C++14
24 / 100
184 ms 10480 KB
#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

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;
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 232 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 31 ms 300 KB Output is correct
20 Correct 33 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 184 ms 10296 KB Output is correct
2 Correct 146 ms 10316 KB Output is correct
3 Correct 139 ms 10348 KB Output is correct
4 Correct 139 ms 10320 KB Output is correct
5 Correct 146 ms 10288 KB Output is correct
6 Correct 142 ms 10284 KB Output is correct
7 Correct 139 ms 10292 KB Output is correct
8 Correct 129 ms 10340 KB Output is correct
9 Correct 141 ms 10372 KB Output is correct
10 Correct 132 ms 10292 KB Output is correct
11 Correct 151 ms 10292 KB Output is correct
12 Correct 122 ms 10328 KB Output is correct
13 Correct 119 ms 10296 KB Output is correct
14 Correct 122 ms 10280 KB Output is correct
15 Correct 128 ms 10368 KB Output is correct
16 Correct 145 ms 10480 KB Output is correct
17 Correct 133 ms 10372 KB Output is correct
18 Correct 138 ms 10324 KB Output is correct
19 Correct 132 ms 10380 KB Output is correct
20 Correct 134 ms 10296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 232 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 31 ms 300 KB Output is correct
20 Correct 33 ms 316 KB Output is correct
21 Incorrect 2 ms 596 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 232 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 31 ms 300 KB Output is correct
20 Correct 33 ms 316 KB Output is correct
21 Correct 184 ms 10296 KB Output is correct
22 Correct 146 ms 10316 KB Output is correct
23 Correct 139 ms 10348 KB Output is correct
24 Correct 139 ms 10320 KB Output is correct
25 Correct 146 ms 10288 KB Output is correct
26 Correct 142 ms 10284 KB Output is correct
27 Correct 139 ms 10292 KB Output is correct
28 Correct 129 ms 10340 KB Output is correct
29 Correct 141 ms 10372 KB Output is correct
30 Correct 132 ms 10292 KB Output is correct
31 Correct 151 ms 10292 KB Output is correct
32 Correct 122 ms 10328 KB Output is correct
33 Correct 119 ms 10296 KB Output is correct
34 Correct 122 ms 10280 KB Output is correct
35 Correct 128 ms 10368 KB Output is correct
36 Correct 145 ms 10480 KB Output is correct
37 Correct 133 ms 10372 KB Output is correct
38 Correct 138 ms 10324 KB Output is correct
39 Correct 132 ms 10380 KB Output is correct
40 Correct 134 ms 10296 KB Output is correct
41 Incorrect 2 ms 596 KB Output isn't correct
42 Halted 0 ms 0 KB -