Submission #758050

# Submission time Handle Problem Language Result Execution time Memory
758050 2023-06-14T05:52:08 Z Adrian_Soriaga Gym Badges (NOI22_gymbadges) C++14
9 / 100
2000 ms 1027220 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<vector<string>> gen(string s){
    vector<vector<string>> ans;
    string a,b,c,d,e,f,g,h,z;
    if (s.size()==1){
        return {{"0"}};
    }
    else if (s.size() ==2){
        return {{"0","1"},{"1","0"}};
    }
    else if (s.size() ==3){
        return {{"0","1","2"},{"0","2","1"},{"1","2","0"},{"1","0","2"},{"2","0","1"},{"2","1","0"}};
    }
    else if (s.size() ==4){
        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(t);
        }
    }
    else if (s.size() ==5){
        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(t);
        }
    }
    else if (s.size() ==6){
        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(t);
        }
    }
    else if (s.size() ==7){
        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(t);
        }
    }
    else if (s.size() ==8){
        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(t);
        }
    }
    else if (s.size() ==9){
        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(t);
        }
    }
    else if (s.size() ==10){
        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(t);
        }
    }
    return ans;
}
int check(vector<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(){
    ios::sync_with_stdio(false);
    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<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::vector<std::vector<std::__cxx11::basic_string<char> > > gen(std::string)':
Main.cpp:17:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:18:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:19:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         for (int k =2;k<s.size(); k++){
      |                       ~^~~~~~~~~
Main.cpp:31:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:32:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:33:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int k =2;k<s.size(); k++)
      |                       ~^~~~~~~~~
Main.cpp:34:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for (int l =3;l<s.size(); l++){
      |                       ~^~~~~~~~~
Main.cpp:48:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:49:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:50:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for (int k =2;k<s.size(); k++)
      |                       ~^~~~~~~~~
Main.cpp:51:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         for (int l =3;l<s.size(); l++)
      |                       ~^~~~~~~~~
Main.cpp:52:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for (int m =4;m<s.size(); m++){
      |                       ~^~~~~~~~~
Main.cpp:68:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:69:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:70:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |         for (int k =2;k<s.size(); k++)
      |                       ~^~~~~~~~~
Main.cpp:71:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |         for (int l =3;l<s.size(); l++)
      |                       ~^~~~~~~~~
Main.cpp:72:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |         for (int m =4;m<s.size(); m++)
      |                       ~^~~~~~~~~
Main.cpp:73:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |         for (int n =5;n<s.size(); n++){
      |                       ~^~~~~~~~~
Main.cpp:91:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:92:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:93:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |         for (int k =2;k<s.size(); k++)
      |                       ~^~~~~~~~~
Main.cpp:94:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |         for (int l =3;l<s.size(); l++)
      |                       ~^~~~~~~~~
Main.cpp:95:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |         for (int m =4;m<s.size(); m++)
      |                       ~^~~~~~~~~
Main.cpp:96:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |         for (int n =5;n<s.size(); n++)
      |                       ~^~~~~~~~~
Main.cpp:97:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |         for (int o =6;o<s.size(); o++){
      |                       ~^~~~~~~~~
Main.cpp:117:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  117 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:118:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  118 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:119:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  119 |         for (int k =2;k<s.size(); k++)
      |                       ~^~~~~~~~~
Main.cpp:120:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  120 |         for (int l =3;l<s.size(); l++)
      |                       ~^~~~~~~~~
Main.cpp:121:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  121 |         for (int m =4;m<s.size(); m++)
      |                       ~^~~~~~~~~
Main.cpp:122:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  122 |         for (int n =5;n<s.size(); n++)
      |                       ~^~~~~~~~~
Main.cpp:123:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  123 |         for (int o =6;o<s.size(); o++)
      |                       ~^~~~~~~~~
Main.cpp:124:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  124 |         for (int p =7;p<s.size(); p++){
      |                       ~^~~~~~~~~
Main.cpp:146:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  146 |         for (int i =0;i<s.size(); i++)
      |                       ~^~~~~~~~~
Main.cpp:147:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  147 |         for (int j =1;j<s.size(); j++)
      |                       ~^~~~~~~~~
Main.cpp:148:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  148 |         for (int k =2;k<s.size(); k++)
      |                       ~^~~~~~~~~
Main.cpp:149:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  149 |         for (int l =3;l<s.size(); l++)
      |                       ~^~~~~~~~~
Main.cpp:150:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  150 |         for (int m =4;m<s.size(); m++)
      |                       ~^~~~~~~~~
Main.cpp:151:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  151 |         for (int n =5;n<s.size(); n++)
      |                       ~^~~~~~~~~
Main.cpp:152:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  152 |         for (int o =6;o<s.size(); o++)
      |                       ~^~~~~~~~~
Main.cpp:153:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  153 |         for (int p =7;p<s.size(); p++)
      |                       ~^~~~~~~~~
Main.cpp:154:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  154 |         for (int q =8;q<s.size(); q++){
      |                       ~^~~~~~~~~
Main.cpp: In function 'int check(std::vector<std::__cxx11::basic_string<char> >, std::vector<int>, std::vector<int>)':
Main.cpp:181:19: 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]
  181 |     for (int i=0;i<action.size();i++){
      |                  ~^~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:204:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  204 |         for (int i=0; i<moves.size();i++){
      |                       ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 29 ms 11912 KB Output is correct
2 Correct 27 ms 11900 KB Output is correct
3 Execution timed out 2125 ms 1027220 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 134 ms 5352 KB Output is correct
2 Correct 135 ms 5312 KB Output is correct
3 Correct 131 ms 5416 KB Output is correct
4 Correct 148 ms 5464 KB Output is correct
5 Correct 137 ms 5276 KB Output is correct
6 Correct 151 ms 5312 KB Output is correct
7 Correct 132 ms 5356 KB Output is correct
8 Correct 140 ms 5228 KB Output is correct
9 Correct 143 ms 5264 KB Output is correct
10 Correct 155 ms 5304 KB Output is correct
11 Correct 107 ms 5324 KB Output is correct
12 Correct 113 ms 5368 KB Output is correct
13 Correct 110 ms 5232 KB Output is correct
14 Correct 110 ms 5288 KB Output is correct
15 Correct 117 ms 5416 KB Output is correct
16 Correct 121 ms 5356 KB Output is correct
17 Correct 151 ms 5228 KB Output is correct
18 Correct 124 ms 5400 KB Output is correct
19 Correct 129 ms 5440 KB Output is correct
20 Correct 122 ms 5428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 11912 KB Output is correct
2 Correct 27 ms 11900 KB Output is correct
3 Execution timed out 2125 ms 1027220 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 11912 KB Output is correct
2 Correct 27 ms 11900 KB Output is correct
3 Execution timed out 2125 ms 1027220 KB Time limit exceeded
4 Halted 0 ms 0 KB -