제출 #201679

#제출 시각아이디문제언어결과실행 시간메모리
201679kostia244Devil's Share (RMI19_devil)C++17
0 / 100
1585 ms504 KiB
#pragma GCC optimize("trapv") #pragma GCC target("avx,avx2,ssse3,sse2,sse,fma,tune=native") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> #include<bits/extc++.h> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define pb push_back using namespace std; using ll = long long; using vi = vector<int>; using pi = pair<int, int>; using vpi = vector<pair<int, int>>; using namespace __gnu_pbds; using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>; int k, a[11], perm[12]; string solve() { int s = 0; for(int i = 1; i <= 9; i++) s += a[i]; int c = 1; pair<ll, string> ans = {1e13, ""}; for(int i = 0; i < s; i++) { while(a[c]==0) c++; perm[i] = c; a[c]--; } do { string t; ll mx = 0, cur = 0, pw = 1; for(int i = 0; i < k; i++) pw*=10; for(int i = 0; i < s; i++) { t.pb(perm[i]+'0'); cur = cur*10 + perm[i]; if(i>=k) cur -= pw*perm[i-k]; mx = max(mx, cur); } if(mx < ans.first) ans = {mx, t}; } while(next_permutation(perm, perm+s)); return ans.second; } void solve2() { } void read() { cin >> k; for(int i = 1; i <= 9; i++) cin >> a[i]; // if(k==2) solve2(); // else cout << solve() << "\n"; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while(t--) read(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...