Submission #477323

#TimeUsernameProblemLanguageResultExecution timeMemory
477323AlexandruabcdeDevil's Share (RMI19_devil)C++14
100 / 100
85 ms7120 KiB
#include <bits/stdc++.h> using namespace std; typedef pair <string, int> PSI; int fr[10]; void do_Testcase () { int K; cin >> K; for (int i = 1; i <= 9; ++ i ) cin >> fr[i]; string S; int cif = 9; for (int i = 1; i <= K-1; ++ i ) { while (fr[cif] == 0) -- cif; S += (cif + '0'); -- fr[cif]; } reverse(S.begin(), S.end()); while (fr[cif] == 0) -- cif; string pt_Max; pt_Max.push_back('0' + cif); PSI Max = {pt_Max, fr[cif]}; vector <PSI> v; for (int i = 0; i < cif; ++ i ) { if (fr[i] <= 0) continue; string aux; aux.push_back(i + '0'); v.push_back({aux, fr[i]}); } for (int i = 0; i < v.size(); ++ i ) { auto it = v[i]; while (it.second >= Max.second) { Max.first += it.first; it.second -= Max.second; } if (it.second > 0) { v.push_back({Max.first + it.first, it.second}); Max.second -= it.second; } } for (int i = 0; i < Max.second; ++ i ) cout << Max.first; cout << S << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int T = 1; cin >> T; for (; T; -- T ) do_Testcase(); return 0; }

Compilation message (stderr)

devil.cpp: In function 'void do_Testcase()':
devil.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::__cxx11::basic_string<char>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i = 0; i < v.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...