답안 #758043

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
758043 2023-06-14T05:37:43 Z Adrian_Soriaga Gym Badges (NOI22_gymbadges) C++14
9 / 100
2000 ms 131768 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
string con(vector<string> s){
    string ans ="";
    for (int i=0; i<s.size();i++){
        ans+= s[i];
    }
    return ans;
}
vector<string> gen(string s){
    vector<string> ans;
    if (s.size()==1){
        return {"0"};
    }
    else if (s.size() ==2){
        return {"01","10"};
    }
    else if (s.size() ==3){
        return {"012","021","120","102","201","210"};
    }
    else if (s.size() ==4){
        string a, b,c;
        for (int i =0;i<s.size(); i++)
        for (int j =1;j<s.size(); j++)
        for (int k =2;k<s.size(); k++){
            vector<string> t = {"0","1","2","3"};
            a= t[i];
            t[i] = t[0]; t[0] = a; 
            b= t[j];
            t[j] = t[1]; t[1] = b; 
            c= t[k];
            t[k] = t[2]; t[2] = c; 
            ans.push_back(con(t));
        }
    }
    else if (s.size() ==5){
        string a,b,c,d;
        for (int i =0;i<s.size(); i++)
        for (int j =1;j<s.size(); j++)
        for (int k =2;k<s.size(); k++)
        for (int l =3;l<s.size(); l++){
            vector<string> t = {"0","1","2","3","4"};
             a= t[i];
            t[i] = t[0]; t[0] = a; 
            b= t[j];
            t[j] = t[1]; t[1] = b; 
             c= t[k];
            t[k] = t[2]; t[2] = c; 
            d= t[l];
            t[l]=  t[3]; t[3] = d;
            ans.push_back(con(t));
        }
    }
    else if (s.size() ==6){
                string a,b,c,d,e;
        for (int i =0;i<s.size(); i++)
        for (int j =1;j<s.size(); j++)
        for (int k =2;k<s.size(); k++)
        for (int l =3;l<s.size(); l++)
        for (int m =4;m<s.size(); m++){
            vector<string> t = {"0","1","2","3","4","5"};
             a= t[i];
            t[i] = t[0]; t[0] = a; 
            b= t[j];
            t[j] = t[1]; t[1] = b; 
          c= t[k];
            t[k] = t[2]; t[2] = c; 
          d= t[l];
            t[l]=  t[3]; t[3] = d;
          e = t[m];
            t[m] = t[4]; t[4] = e;
            ans.push_back(con(t));
        }
    }
    else if (s.size() ==7){
        string a,b,c,d,e,f;
        for (int i =0;i<s.size(); i++)
        for (int j =1;j<s.size(); j++)
        for (int k =2;k<s.size(); k++)
        for (int l =3;l<s.size(); l++)
        for (int m =4;m<s.size(); m++)
        for (int n =5;n<s.size(); n++){
            vector<string> t = {"0","1","2","3","4","5","6"};
             a= t[i];
            t[i] = t[0]; t[0] = a; 
             b= t[j];
            t[j] = t[1]; t[1] = b; 
            c= t[k];
            t[k] = t[2]; t[2] = c; 
             d= t[l];
            t[l]=  t[3]; t[3] = d;
             e = t[m];
            t[m] = t[4]; t[4] = e;
             f = t[n];
            t[n] = t[5]; t[5] = f;
            ans.push_back(con(t));
        }
    }
    else if (s.size() ==8){
        string a,b,c,d,e,f,g;
        for (int i =0;i<s.size(); i++)
        for (int j =1;j<s.size(); j++)
        for (int k =2;k<s.size(); k++)
        for (int l =3;l<s.size(); l++)
        for (int m =4;m<s.size(); m++)
        for (int n =5;n<s.size(); n++)
        for (int o =6;o<s.size(); o++){
            vector<string> t = {"0","1","2","3","4","5","6","7"};
             a= t[i];
            t[i] = t[0]; t[0] = a; 
            b= t[j];
            t[j] = t[1]; t[1] = b; 
             c= t[k];
            t[k] = t[2]; t[2] = c; 
             d= t[l];
            t[l]=  t[3]; t[3] = d;
             e = t[m];
            t[m] = t[4]; t[4] = e;
             f = t[n];
            t[n] = t[5]; t[5] = f;
             g = t[o];
            t[o] = t[6]; t[6] = g;
            ans.push_back(con(t));
        }
    }
    else if (s.size() ==9){
        string a,b,c,d,e,f,g,h;
        for (int i =0;i<s.size(); i++)
        for (int j =1;j<s.size(); j++)
        for (int k =2;k<s.size(); k++)
        for (int l =3;l<s.size(); l++)
        for (int m =4;m<s.size(); m++)
        for (int n =5;n<s.size(); n++)
        for (int o =6;o<s.size(); o++)
        for (int p =7;p<s.size(); p++){
            vector<string> t = {"0","1","2","3","4","5","6","7","8"};
             a= t[i];
            t[i] = t[0]; t[0] = a; 
             b= t[j];
            t[j] = t[1]; t[1] = b; 
            c= t[k];
            t[k] = t[2]; t[2] = c; 
             d= t[l];
            t[l]=  t[3]; t[3] = d;
             e = t[m];
            t[m] = t[4]; t[4] = e;
             f = t[n];
            t[n] = t[5]; t[5] = f;
            g = t[o];
            t[o] = t[6]; t[6] = g;
            h = t[p];
            t[p] = t[7]; t[7] = h;
            ans.push_back(con(t));
        }
    }
    else if (s.size() ==10){
        string a,b,c,d,e,f,g,h,z;
        for (int i =0;i<s.size(); i++)
        for (int j =1;j<s.size(); j++)
        for (int k =2;k<s.size(); k++)
        for (int l =3;l<s.size(); l++)
        for (int m =4;m<s.size(); m++)
        for (int n =5;n<s.size(); n++)
        for (int o =6;o<s.size(); o++)
        for (int p =7;p<s.size(); p++)
        for (int q =8;q<s.size(); q++){
            vector<string> t = {"0","1","2","3","4","5","6","7","8","9"};
            a= t[i];
            t[i] = t[0]; t[0] = a; 
            b= t[j];
            t[j] = t[1]; t[1] = b; 
             c= t[k];
            t[k] = t[2]; t[2] = c; 
             d= t[l];
            t[l]=  t[3]; t[3] = d;
            e = t[m];
            t[m] = t[4]; t[4] = e;
            f = t[n];
            t[n] = t[5]; t[5] = f;
             g = t[o];
            t[o] = t[6]; t[6] = g;
             h = t[p];
            t[p] = t[7]; t[7] = h;
             z= t[q];
            t[q] = t[8]; t[8] = q;
            ans.push_back(con(t));
        }
    }
    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){
        string z="";
        int m =0;
        for (int i=0; i<n;i++){z+="1";}
        vector<string> moves = gen(z);
        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 'std::string con(std::vector<std::__cxx11::basic_string<char> >)':
Main.cpp:6:20: 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]
    6 |     for (int i=0; i<s.size();i++){
      |                   ~^~~~~~~~~
Main.cpp: In function 'std::vector<std::__cxx11::basic_string<char> > gen(std::string)':
Main.cpp:24:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:25:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:26:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for (int k =2;k<s.size(); k++){
      |                       ~^~~~~~~~~
Main.cpp:39:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:40:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:41:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for (int k =2;k<s.size(); k++)
      |                       ~^~~~~~~~~
Main.cpp:42:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for (int l =3;l<s.size(); l++){
      |                       ~^~~~~~~~~
Main.cpp:57:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:58:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:59:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         for (int k =2;k<s.size(); k++)
      |                       ~^~~~~~~~~
Main.cpp:60:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         for (int l =3;l<s.size(); l++)
      |                       ~^~~~~~~~~
Main.cpp:61:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for (int m =4;m<s.size(); m++){
      |                       ~^~~~~~~~~
Main.cpp:78:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:79:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:80:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |         for (int k =2;k<s.size(); k++)
      |                       ~^~~~~~~~~
Main.cpp:81:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |         for (int l =3;l<s.size(); l++)
      |                       ~^~~~~~~~~
Main.cpp:82:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |         for (int m =4;m<s.size(); m++)
      |                       ~^~~~~~~~~
Main.cpp:83:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |         for (int n =5;n<s.size(); n++){
      |                       ~^~~~~~~~~
Main.cpp:102:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  102 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:103:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  103 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:104:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  104 |         for (int k =2;k<s.size(); k++)
      |                       ~^~~~~~~~~
Main.cpp:105:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |         for (int l =3;l<s.size(); l++)
      |                       ~^~~~~~~~~
Main.cpp:106:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  106 |         for (int m =4;m<s.size(); m++)
      |                       ~^~~~~~~~~
Main.cpp:107:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  107 |         for (int n =5;n<s.size(); n++)
      |                       ~^~~~~~~~~
Main.cpp:108:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  108 |         for (int o =6;o<s.size(); o++){
      |                       ~^~~~~~~~~
Main.cpp:129:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  129 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:130:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  130 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:131:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  131 |         for (int k =2;k<s.size(); k++)
      |                       ~^~~~~~~~~
Main.cpp:132:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  132 |         for (int l =3;l<s.size(); l++)
      |                       ~^~~~~~~~~
Main.cpp:133:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  133 |         for (int m =4;m<s.size(); m++)
      |                       ~^~~~~~~~~
Main.cpp:134:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  134 |         for (int n =5;n<s.size(); n++)
      |                       ~^~~~~~~~~
Main.cpp:135:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  135 |         for (int o =6;o<s.size(); o++)
      |                       ~^~~~~~~~~
Main.cpp:136:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  136 |         for (int p =7;p<s.size(); p++){
      |                       ~^~~~~~~~~
Main.cpp:159:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  159 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:160:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  160 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:161:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  161 |         for (int k =2;k<s.size(); k++)
      |                       ~^~~~~~~~~
Main.cpp:162:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  162 |         for (int l =3;l<s.size(); l++)
      |                       ~^~~~~~~~~
Main.cpp:163:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  163 |         for (int m =4;m<s.size(); m++)
      |                       ~^~~~~~~~~
Main.cpp:164:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  164 |         for (int n =5;n<s.size(); n++)
      |                       ~^~~~~~~~~
Main.cpp:165:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  165 |         for (int o =6;o<s.size(); o++)
      |                       ~^~~~~~~~~
Main.cpp:166:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  166 |         for (int p =7;p<s.size(); p++)
      |                       ~^~~~~~~~~
Main.cpp:167:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  167 |         for (int q =8;q<s.size(); q++){
      |                       ~^~~~~~~~~
Main.cpp: In function 'int check(std::string, std::vector<int>, std::vector<int>)':
Main.cpp:194:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  194 |     for (int i=0;i<action.size();i++){
      |                  ~^~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:216: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]
  216 |         for (int i=0; i<moves.size();i++){
      |                       ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 2376 KB Output is correct
2 Correct 25 ms 2376 KB Output is correct
3 Execution timed out 2078 ms 131768 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 397 ms 5280 KB Output is correct
2 Correct 412 ms 5252 KB Output is correct
3 Correct 389 ms 5220 KB Output is correct
4 Correct 394 ms 5288 KB Output is correct
5 Correct 388 ms 5308 KB Output is correct
6 Correct 402 ms 5380 KB Output is correct
7 Correct 370 ms 5256 KB Output is correct
8 Correct 354 ms 5280 KB Output is correct
9 Correct 359 ms 5232 KB Output is correct
10 Correct 371 ms 5396 KB Output is correct
11 Correct 319 ms 5320 KB Output is correct
12 Correct 344 ms 5324 KB Output is correct
13 Correct 317 ms 5204 KB Output is correct
14 Correct 342 ms 5304 KB Output is correct
15 Correct 325 ms 5240 KB Output is correct
16 Correct 346 ms 5304 KB Output is correct
17 Correct 351 ms 5296 KB Output is correct
18 Correct 351 ms 5304 KB Output is correct
19 Correct 340 ms 5272 KB Output is correct
20 Correct 347 ms 5284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 2376 KB Output is correct
2 Correct 25 ms 2376 KB Output is correct
3 Execution timed out 2078 ms 131768 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 2376 KB Output is correct
2 Correct 25 ms 2376 KB Output is correct
3 Execution timed out 2078 ms 131768 KB Time limit exceeded
4 Halted 0 ms 0 KB -