Submission #338027

#TimeUsernameProblemLanguageResultExecution timeMemory
338027NimbostratusDevil's Share (RMI19_devil)C++17
0 / 100
1599 ms620 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e15; int TC; int K,cnt[15]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("in","r",stdin); //freopen("out","w",stdout); cin >> TC; ll a = 1; while(TC--) { string perm,ans; ll mn = INF; cin >> K; for(int i=1;i<=9;i++) cin >> cnt[i]; for(int i=1;i<=9;i++) for(int j=1;j<=cnt[i];j++) perm += char('0' + i); do { ll cur = stoll(perm.substr(0,K)); ll mx = cur; for(int i=1;i+K-1<perm.size();i++) { cur %= (ll)pow(10,K-1); cur *= 10; cur += (perm[i+K-1] - '0'); mx = max(mx,cur); } if(mn > mx) { mn = mx; ans = perm; } } while(next_permutation(perm.begin(),perm.end())); cout << ans << endl; } }

Compilation message (stderr)

devil.cpp: In function 'int32_t main()':
devil.cpp:31:21: 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=1;i+K-1<perm.size();i++)
      |                ~~~~~^~~~~~~~~~~~
devil.cpp:17:5: warning: unused variable 'a' [-Wunused-variable]
   17 |  ll a = 1;
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...