제출 #758264

#제출 시각아이디문제언어결과실행 시간메모리
758264Adrian_SoriagaGym Badges (NOI22_gymbadges)C++14
24 / 100
778 ms131760 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...