Submission #258113

#TimeUsernameProblemLanguageResultExecution timeMemory
258113tqbfjotldDevil's Share (RMI19_devil)C++14
0 / 100
1599 ms256 KiB
#include <bits/stdc++.h> using namespace std; int arr[11]; string mult(string s, int num){ string res = ""; for (int x = 0; x<num; x++){ res += s; } // printf("was multing %s by %d\n",s.c_str(),num); return res; } int main(){ int test; scanf("%d",&test); while (test--){ int k,n=0; scanf("%d",&k); for (int x = 1; x<10; x++){ scanf("%d",&arr[x]); n+= arr[x]; } multiset<pair<string,int> >s; string curbig = ""; int temp = 0; int curnum = 0; for (int x = 1; x<10; x++){ string te = ""; te += ('0'+x); if (arr[x]!=0) temp += arr[x]; //printf("temp is now %d\n",temp); if (temp>n-k&&curnum==0){ curbig += ('0'+x); curnum = arr[x]-(temp-n+k-1); //printf("curbig should be %c\n",'0'+x); //printf("curbig is [%s]\n",curbig.c_str()); s.insert({te,temp-n+k-1}); }else s.insert({te,arr[x]}); } while (curbig.size()<k){ //printf("curbig is %s, curnum is %d\n",curbig.c_str(),curnum); auto it = s.begin(); //printf("first item is %s,%d\n",(*it).first.c_str(),(*it).second); if ((*it).first>curbig){ curbig = mult(curbig,curnum); curnum = 1; continue; } if ((*it).second<curnum){ curnum -= (*it).second; string t = (*it).first; int t2 = (*it).second; s.erase(it); s.insert({curbig+t,t2}); continue; } string t = (*it).first; int num = (*it).second; s.erase(it); if (num-curnum>0){ s.insert({t,num-curnum}); } curbig += t; curnum = num; } printf("%s",mult(curbig,curnum).c_str()); for (auto x : s){ printf("%s",mult(x.first,x.second).c_str()); } printf("\n"); } }

Compilation message (stderr)

devil.cpp: In function 'int main()':
devil.cpp:44:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (curbig.size()<k){
                ~~~~~~~~~~~~~^~
devil.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&test);
     ~~~~~^~~~~~~~~~~~
devil.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
         ~~~~~^~~~~~~~~
devil.cpp:22:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&arr[x]);
             ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...