Submission #338099

#TimeUsernameProblemLanguageResultExecution timeMemory
338099NimbostratusDevil's Share (RMI19_devil)C++17
0 / 100
1583 ms500 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; int sum = 0; for(int i=1;i<=9;i++) cin >> cnt[i] , sum += cnt[i]; for(int i=1;i<=9;i++) for(int j=1;j<=cnt[i];j++) perm += char('0' + i); do { ll cur = 0; for(int i=0;i<=K-1;i++) { cur *= 10; cur += (perm[i]-'0'); } ll mx = cur; for(int i=1;i+K-1<sum;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: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...