# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
332258 | IgorI | Devil's Share (RMI19_devil) | C++17 | 42 ms | 1772 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
void solve()
{
int n = 10;
int k = 0;
cin >> k;
vector<int> d(n);
for (int i = 1; i < n; i++)
cin >> d[i];
if (d[1] == 0)
{
cout << string(d[2], '2') << "\n";
return;
}
string s(k - 1, '0');
for (int i = k - 2; i >= 0; i--)
{
if (d[2])
d[2]--, s[i] = '2';
else
d[1]--, s[i] = '1';
}
int c1 = d[1], c2 = d[2];
vector<int> h(c1, c2 / c1);
int add = c2 % c1;
//cout << c2 << " " << c1 << endl;
if (add > 0)
{
for (int st = h.size(); st >= 1; st--)
{
if (h.size() / st >= add)
{
for (int i = st - 1; i < h.size(); i += st)
{
if (add)
add--, h[i]++;
}
//cout << add << endl;
break;
}
}
}
reverse(h.begin(), h.end());
for (auto e : h)
{
for (int i = 0; i < e; i++)
cout << "2";
cout << "1";
}
cout << s << "\n";
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |