# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
162911 |
2019-11-10T09:17:07 Z |
mrboorger |
Gift (IZhO18_nicegift) |
C++17 |
|
2000 ms |
16852 KB |
//#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define ld long double
#define sqr(x) (x) * (x)
using namespace std;
using namespace __gnu_pbds;
int main()
{
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // LOCAL
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, k;
cin >> n >> k;
vector <pair <ll, int>> a;
ll sum = 0;
for(int i = 0; i < n; ++i)
{
int x;
cin >> x;
sum += x;
if (x > 0) a.pb({x, i});
}
// if (sum % k > 0)
// {
// cout << -1;
// return 0;
// }
vector <pair <ll, vector <int>>> ans;
vector <int> cl;
sort(a.rbegin(), a.rend());
while(int(a.size()) >= k)
{
ans.pb({1, cl});
for(int i = 0; i < k; ++i)
{
ans.back().S.pb(a[i].S);
a[i].F -= 1;
}
sort(a.rbegin(), a.rend());
while(!a.empty() && a.back().F == 0)
a.pop_back();
}
if (!a.empty())
{
cout << -1;
}
else
{
cout << int(ans.size()) << '\n';
for(int i = 0; i < int(ans.size()); ++i)
{
cout << ans[i].F << ' ';
for(int j = 0; j < k; ++j)
cout << ans[i].S[j] + 1 << ' ';
cout << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
n=4 |
2 |
Correct |
2 ms |
376 KB |
n=3 |
3 |
Correct |
2 ms |
380 KB |
n=3 |
4 |
Correct |
2 ms |
376 KB |
n=4 |
5 |
Correct |
2 ms |
376 KB |
n=4 |
6 |
Correct |
2 ms |
376 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
n=4 |
2 |
Correct |
2 ms |
376 KB |
n=3 |
3 |
Correct |
2 ms |
380 KB |
n=3 |
4 |
Correct |
2 ms |
376 KB |
n=4 |
5 |
Correct |
2 ms |
376 KB |
n=4 |
6 |
Correct |
2 ms |
376 KB |
n=2 |
7 |
Correct |
2 ms |
256 KB |
n=5 |
8 |
Correct |
4 ms |
1144 KB |
n=8 |
9 |
Correct |
10 ms |
1268 KB |
n=14 |
10 |
Correct |
6 ms |
1144 KB |
n=11 |
11 |
Execution timed out |
2062 ms |
1652 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
n=4 |
2 |
Correct |
2 ms |
376 KB |
n=3 |
3 |
Correct |
2 ms |
380 KB |
n=3 |
4 |
Correct |
2 ms |
376 KB |
n=4 |
5 |
Correct |
2 ms |
376 KB |
n=4 |
6 |
Correct |
2 ms |
376 KB |
n=2 |
7 |
Correct |
2 ms |
256 KB |
n=5 |
8 |
Correct |
4 ms |
1144 KB |
n=8 |
9 |
Correct |
10 ms |
1268 KB |
n=14 |
10 |
Correct |
6 ms |
1144 KB |
n=11 |
11 |
Execution timed out |
2062 ms |
1652 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2025 ms |
16852 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
n=4 |
2 |
Correct |
2 ms |
376 KB |
n=3 |
3 |
Correct |
2 ms |
380 KB |
n=3 |
4 |
Correct |
2 ms |
376 KB |
n=4 |
5 |
Correct |
2 ms |
376 KB |
n=4 |
6 |
Correct |
2 ms |
376 KB |
n=2 |
7 |
Correct |
2 ms |
256 KB |
n=5 |
8 |
Correct |
4 ms |
1144 KB |
n=8 |
9 |
Correct |
10 ms |
1268 KB |
n=14 |
10 |
Correct |
6 ms |
1144 KB |
n=11 |
11 |
Execution timed out |
2062 ms |
1652 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |