# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
258622 | 2020-08-06T09:16:31 Z | dantoh000 | Devil's Share (RMI19_devil) | C++14 | 443 ms | 1912 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int k; int d[10]; int ans[100005]; int n; int main(){ int TC; scanf("%d",&TC); while (TC--){ scanf("%d",&k); n = 0; for (int i = 1; i <= 9; i++){ scanf("%d",&d[i]); n += d[i]; } if (k == 2){ int F = 1, S = 9; for (int i = n-1; i >= 0; i--){ while (d[F] == 0) F++; while (d[S] == 0) S--; //printf("%d digit: %d %d\n",i,F,S); if ((n-i) % 2 == 1){ ans[i] = S; d[S]--; } else{ ans[i] = F; d[F]--; } } for (int i = 0; i < n; i++){ printf("%d",ans[i]); } printf("\n"); } else if (n <= 12){ vector<int> v; for (int i = 1; i <= 4; i++) for (int j = 0; j < d[i]; j++) v.emplace_back(i); vector<int> ans(n); ll best = 100000000000; do{ ll mx = 0; for (int i = 0; i <= n-k; i++){ ll cur = 0; for (int j = 0; j < k; j++){ cur = (10*cur + v[j+i]); } mx = max(cur,mx); } if (best > mx){ //printf("%d: ",mx); best = mx; for (int i = 0; i < n; i++){ ans[i] = v[i]; //printf("%d",ans[i]); } //printf("\n"); } } while (next_permutation(v.begin(),v.end())); for (int i = 0; i < n; i++){ printf("%d",ans[i]); } printf("\n"); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 443 ms | 640 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 125 ms | 1912 KB | Output is correct |
2 | Correct | 107 ms | 1784 KB | Output is correct |
3 | Correct | 109 ms | 1784 KB | Output is correct |
4 | Correct | 132 ms | 1912 KB | Output is correct |
5 | Correct | 80 ms | 1272 KB | Output is correct |
6 | Correct | 80 ms | 1272 KB | Output is correct |
7 | Correct | 80 ms | 1272 KB | Output is correct |
8 | Correct | 79 ms | 1400 KB | Output is correct |
9 | Correct | 78 ms | 1656 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 36 ms | 888 KB | Token parameter [name=X] equals to "111111111111111111111111111111121212121212", doesn't correspond to pattern "[0-9]{26}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 443 ms | 640 KB | Output isn't correct |