#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<string> gen(int n){
vector<string> t = {"0","01", "012","0123","01234","012345","0123456","01234567","012345678","0123456789"};
vector<string> ans;
string s= t[n-1];
do{ans.push_back(s);} while (next_permutation(s.begin(),s.end()));
return ans;
}
int check(string action,vector<int> exp, vector<int> levels){
int ans =0, ce= 0;
for (int i=0;i<action.size();i++){
int n = stoi(action[i]+ string());
if (ce<=levels[n]) {ans += 1; ce += exp[n];}
else break;
}
return ans;
}
int main(){
int n,x,ce=0,c=0; cin>>n;
vector<int> exp, levels;
for (int i =0; i<n; i++){
cin>>x;
exp.push_back(x);}
for (int i =0; i<n; i++){
cin>>x;
levels.push_back(x);
}
if (n<=10){
int m =0;
vector<string> moves = gen(n);
for (int i=0; i<moves.size();i++){
m = max(m,check(moves[i],exp,levels));
}
cout<<m;}
else{
sort(exp.begin(),exp.end());
while (ce<=levels[0]){
if (c==n){break;}
ce += exp[c];
c+=1;
}
cout<<c;}
}
Compilation message
Main.cpp: In function 'int check(std::string, std::vector<int>, std::vector<int>)':
Main.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for (int i=0;i<action.size();i++){
| ~^~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:33:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int i=0; i<moves.size();i++){
| ~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2376 KB |
Output is correct |
2 |
Correct |
6 ms |
2376 KB |
Output is correct |
3 |
Correct |
576 ms |
131696 KB |
Output is correct |
4 |
Correct |
524 ms |
131720 KB |
Output is correct |
5 |
Correct |
516 ms |
131752 KB |
Output is correct |
6 |
Correct |
528 ms |
131636 KB |
Output is correct |
7 |
Correct |
55 ms |
16808 KB |
Output is correct |
8 |
Correct |
553 ms |
131676 KB |
Output is correct |
9 |
Correct |
8 ms |
2376 KB |
Output is correct |
10 |
Correct |
8 ms |
2464 KB |
Output is correct |
11 |
Correct |
8 ms |
2500 KB |
Output is correct |
12 |
Correct |
8 ms |
2376 KB |
Output is correct |
13 |
Correct |
632 ms |
131760 KB |
Output is correct |
14 |
Correct |
576 ms |
131704 KB |
Output is correct |
15 |
Correct |
566 ms |
131752 KB |
Output is correct |
16 |
Correct |
64 ms |
16828 KB |
Output is correct |
17 |
Correct |
70 ms |
16764 KB |
Output is correct |
18 |
Correct |
9 ms |
2376 KB |
Output is correct |
19 |
Correct |
778 ms |
131640 KB |
Output is correct |
20 |
Correct |
775 ms |
131668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
441 ms |
6764 KB |
Output is correct |
2 |
Correct |
401 ms |
6776 KB |
Output is correct |
3 |
Correct |
404 ms |
7152 KB |
Output is correct |
4 |
Correct |
409 ms |
7296 KB |
Output is correct |
5 |
Correct |
395 ms |
5848 KB |
Output is correct |
6 |
Correct |
367 ms |
7284 KB |
Output is correct |
7 |
Correct |
368 ms |
9928 KB |
Output is correct |
8 |
Correct |
367 ms |
6056 KB |
Output is correct |
9 |
Correct |
365 ms |
5824 KB |
Output is correct |
10 |
Correct |
374 ms |
5760 KB |
Output is correct |
11 |
Correct |
351 ms |
5688 KB |
Output is correct |
12 |
Correct |
345 ms |
6588 KB |
Output is correct |
13 |
Correct |
348 ms |
5660 KB |
Output is correct |
14 |
Correct |
347 ms |
6572 KB |
Output is correct |
15 |
Correct |
330 ms |
7048 KB |
Output is correct |
16 |
Correct |
375 ms |
6668 KB |
Output is correct |
17 |
Correct |
438 ms |
5880 KB |
Output is correct |
18 |
Correct |
346 ms |
6376 KB |
Output is correct |
19 |
Correct |
346 ms |
6460 KB |
Output is correct |
20 |
Correct |
358 ms |
6972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2376 KB |
Output is correct |
2 |
Correct |
6 ms |
2376 KB |
Output is correct |
3 |
Correct |
576 ms |
131696 KB |
Output is correct |
4 |
Correct |
524 ms |
131720 KB |
Output is correct |
5 |
Correct |
516 ms |
131752 KB |
Output is correct |
6 |
Correct |
528 ms |
131636 KB |
Output is correct |
7 |
Correct |
55 ms |
16808 KB |
Output is correct |
8 |
Correct |
553 ms |
131676 KB |
Output is correct |
9 |
Correct |
8 ms |
2376 KB |
Output is correct |
10 |
Correct |
8 ms |
2464 KB |
Output is correct |
11 |
Correct |
8 ms |
2500 KB |
Output is correct |
12 |
Correct |
8 ms |
2376 KB |
Output is correct |
13 |
Correct |
632 ms |
131760 KB |
Output is correct |
14 |
Correct |
576 ms |
131704 KB |
Output is correct |
15 |
Correct |
566 ms |
131752 KB |
Output is correct |
16 |
Correct |
64 ms |
16828 KB |
Output is correct |
17 |
Correct |
70 ms |
16764 KB |
Output is correct |
18 |
Correct |
9 ms |
2376 KB |
Output is correct |
19 |
Correct |
778 ms |
131640 KB |
Output is correct |
20 |
Correct |
775 ms |
131668 KB |
Output is correct |
21 |
Incorrect |
5 ms |
340 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2376 KB |
Output is correct |
2 |
Correct |
6 ms |
2376 KB |
Output is correct |
3 |
Correct |
576 ms |
131696 KB |
Output is correct |
4 |
Correct |
524 ms |
131720 KB |
Output is correct |
5 |
Correct |
516 ms |
131752 KB |
Output is correct |
6 |
Correct |
528 ms |
131636 KB |
Output is correct |
7 |
Correct |
55 ms |
16808 KB |
Output is correct |
8 |
Correct |
553 ms |
131676 KB |
Output is correct |
9 |
Correct |
8 ms |
2376 KB |
Output is correct |
10 |
Correct |
8 ms |
2464 KB |
Output is correct |
11 |
Correct |
8 ms |
2500 KB |
Output is correct |
12 |
Correct |
8 ms |
2376 KB |
Output is correct |
13 |
Correct |
632 ms |
131760 KB |
Output is correct |
14 |
Correct |
576 ms |
131704 KB |
Output is correct |
15 |
Correct |
566 ms |
131752 KB |
Output is correct |
16 |
Correct |
64 ms |
16828 KB |
Output is correct |
17 |
Correct |
70 ms |
16764 KB |
Output is correct |
18 |
Correct |
9 ms |
2376 KB |
Output is correct |
19 |
Correct |
778 ms |
131640 KB |
Output is correct |
20 |
Correct |
775 ms |
131668 KB |
Output is correct |
21 |
Correct |
441 ms |
6764 KB |
Output is correct |
22 |
Correct |
401 ms |
6776 KB |
Output is correct |
23 |
Correct |
404 ms |
7152 KB |
Output is correct |
24 |
Correct |
409 ms |
7296 KB |
Output is correct |
25 |
Correct |
395 ms |
5848 KB |
Output is correct |
26 |
Correct |
367 ms |
7284 KB |
Output is correct |
27 |
Correct |
368 ms |
9928 KB |
Output is correct |
28 |
Correct |
367 ms |
6056 KB |
Output is correct |
29 |
Correct |
365 ms |
5824 KB |
Output is correct |
30 |
Correct |
374 ms |
5760 KB |
Output is correct |
31 |
Correct |
351 ms |
5688 KB |
Output is correct |
32 |
Correct |
345 ms |
6588 KB |
Output is correct |
33 |
Correct |
348 ms |
5660 KB |
Output is correct |
34 |
Correct |
347 ms |
6572 KB |
Output is correct |
35 |
Correct |
330 ms |
7048 KB |
Output is correct |
36 |
Correct |
375 ms |
6668 KB |
Output is correct |
37 |
Correct |
438 ms |
5880 KB |
Output is correct |
38 |
Correct |
346 ms |
6376 KB |
Output is correct |
39 |
Correct |
346 ms |
6460 KB |
Output is correct |
40 |
Correct |
358 ms |
6972 KB |
Output is correct |
41 |
Incorrect |
5 ms |
340 KB |
Output isn't correct |
42 |
Halted |
0 ms |
0 KB |
- |