#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.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 {
cout << "WOOPS" << endl;
}
}
// else if (len >= 1 && len <= 10){
// unordered_map<int,pair<ll,ll> > gyms;
// for(int i = 1; i <= len; i++){
// gyms[i] = {lvlcap.at(i),lvlgained.at(i)};
// }
// recurse(gyms,0,0);
// cout << max_count << 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;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
133 ms |
10328 KB |
Output is correct |
2 |
Correct |
149 ms |
10340 KB |
Output is correct |
3 |
Correct |
148 ms |
10304 KB |
Output is correct |
4 |
Correct |
132 ms |
10272 KB |
Output is correct |
5 |
Correct |
134 ms |
10316 KB |
Output is correct |
6 |
Correct |
146 ms |
10392 KB |
Output is correct |
7 |
Correct |
124 ms |
10384 KB |
Output is correct |
8 |
Correct |
124 ms |
10264 KB |
Output is correct |
9 |
Correct |
135 ms |
10296 KB |
Output is correct |
10 |
Correct |
130 ms |
10332 KB |
Output is correct |
11 |
Correct |
118 ms |
10360 KB |
Output is correct |
12 |
Correct |
122 ms |
10468 KB |
Output is correct |
13 |
Correct |
133 ms |
10384 KB |
Output is correct |
14 |
Correct |
115 ms |
10364 KB |
Output is correct |
15 |
Correct |
112 ms |
10300 KB |
Output is correct |
16 |
Correct |
126 ms |
10384 KB |
Output is correct |
17 |
Correct |
126 ms |
10300 KB |
Output is correct |
18 |
Correct |
129 ms |
10392 KB |
Output is correct |
19 |
Correct |
125 ms |
10312 KB |
Output is correct |
20 |
Correct |
131 ms |
10272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |