# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
829240 | Hanksburger | Cookies (JOI23_cookies) | C++17 | 66 ms | 1152 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;
vector<pair<int, int> > vec;
vector<vector<int> > ans;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, k, sum=0;
cin >> n;
for (int i=0; i<n; i++)
{
int x;
cin >> x;
vec.push_back({x, i+1});
}
cin >> m >> k;
for (int i=0; i<n; i++)
sum+=vec[i].first;
if (sum%k)
{
cout << -1;
return 0;
}
for (int i=0; i<sum/k; i++)
{
sort(vec.begin(), vec.end(), greater<pair<int, int> >());
vector<int> tmp;
for (int j=0; j<k; j++)
{
if (!vec[j].first)
{
cout << -1;
return 0;
}
vec[j].first--;
tmp.push_back(vec[j].second);
}
ans.push_back(tmp);
}
cout << ans.size() << '\n';
for (int i=0; i<ans.size(); i++)
{
cout << ans[i].size() << ' ';
for (int j=0; j<ans[i].size(); j++)
cout << ans[i][j] << ' ';
cout << '\n';
}
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |