이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;}
}
컴파일 시 표준 에러 (stderr) 메시지
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |