# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
683495 |
2023-01-18T15:18:44 Z |
opPO |
Gift (IZhO18_nicegift) |
C++17 |
|
2000 ms |
234944 KB |
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define pb push_back
#define ld long double
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define vec vector
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
const ld eps = 1e-6;
const int mod = 998244353;
const int oo = 2e9;
const ll OO = 2e18;
const int N = 1e5 + 10;
bool cmp(pii a, pii b)
{
return a > b;
}
void solve()
{
int n, k;
cin >> n >> k;
vec<int> a(n + 1);
set<pii, decltype(cmp)*> setik(cmp);
for (int i = 1; i <= n; i++)
{
cin >> a[i];
setik.insert({a[i], i});
}
vec<vec<int>> operations;
while (sz(setik) >= k)
{
vec<int> op = {1};
vec<pii> q;
for (int i = 0; i < k; i++)
{
pii cur = *setik.begin(); setik.erase(setik.begin());
op.pb(cur.s);
cur.f--;
q.pb(cur);
}
for (int i = 0; i < k; i++) if (q[i].f != 0) setik.insert(q[i]);
operations.pb(op);
}
if (sz(setik) != 0)
{
cout << -1;
return;
}
cout << sz(operations) << "\n";
for (auto &operation : operations)
{
for (auto &x : operation) cout << x << " ";
cout << "\n";
}
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n=4 |
2 |
Correct |
1 ms |
212 KB |
n=3 |
3 |
Correct |
1 ms |
324 KB |
n=3 |
4 |
Correct |
1 ms |
212 KB |
n=4 |
5 |
Correct |
0 ms |
212 KB |
n=4 |
6 |
Correct |
0 ms |
320 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n=4 |
2 |
Correct |
1 ms |
212 KB |
n=3 |
3 |
Correct |
1 ms |
324 KB |
n=3 |
4 |
Correct |
1 ms |
212 KB |
n=4 |
5 |
Correct |
0 ms |
212 KB |
n=4 |
6 |
Correct |
0 ms |
320 KB |
n=2 |
7 |
Correct |
0 ms |
212 KB |
n=5 |
8 |
Correct |
4 ms |
980 KB |
n=8 |
9 |
Correct |
8 ms |
1156 KB |
n=14 |
10 |
Correct |
5 ms |
980 KB |
n=11 |
11 |
Correct |
44 ms |
6528 KB |
n=50000 |
12 |
Correct |
47 ms |
6608 KB |
n=50000 |
13 |
Correct |
28 ms |
3328 KB |
n=10 |
14 |
Correct |
33 ms |
2992 KB |
n=685 |
15 |
Correct |
34 ms |
3280 KB |
n=623 |
16 |
Correct |
18 ms |
2008 KB |
n=973 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n=4 |
2 |
Correct |
1 ms |
212 KB |
n=3 |
3 |
Correct |
1 ms |
324 KB |
n=3 |
4 |
Correct |
1 ms |
212 KB |
n=4 |
5 |
Correct |
0 ms |
212 KB |
n=4 |
6 |
Correct |
0 ms |
320 KB |
n=2 |
7 |
Correct |
0 ms |
212 KB |
n=5 |
8 |
Correct |
4 ms |
980 KB |
n=8 |
9 |
Correct |
8 ms |
1156 KB |
n=14 |
10 |
Correct |
5 ms |
980 KB |
n=11 |
11 |
Correct |
44 ms |
6528 KB |
n=50000 |
12 |
Correct |
47 ms |
6608 KB |
n=50000 |
13 |
Correct |
28 ms |
3328 KB |
n=10 |
14 |
Correct |
33 ms |
2992 KB |
n=685 |
15 |
Correct |
34 ms |
3280 KB |
n=623 |
16 |
Correct |
18 ms |
2008 KB |
n=973 |
17 |
Correct |
38 ms |
3056 KB |
n=989 |
18 |
Correct |
18 ms |
1252 KB |
n=563 |
19 |
Correct |
30 ms |
1692 KB |
n=592 |
20 |
Correct |
26 ms |
1696 KB |
n=938 |
21 |
Correct |
18 ms |
1480 KB |
n=747 |
22 |
Correct |
20 ms |
1620 KB |
n=991 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2082 ms |
234944 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n=4 |
2 |
Correct |
1 ms |
212 KB |
n=3 |
3 |
Correct |
1 ms |
324 KB |
n=3 |
4 |
Correct |
1 ms |
212 KB |
n=4 |
5 |
Correct |
0 ms |
212 KB |
n=4 |
6 |
Correct |
0 ms |
320 KB |
n=2 |
7 |
Correct |
0 ms |
212 KB |
n=5 |
8 |
Correct |
4 ms |
980 KB |
n=8 |
9 |
Correct |
8 ms |
1156 KB |
n=14 |
10 |
Correct |
5 ms |
980 KB |
n=11 |
11 |
Correct |
44 ms |
6528 KB |
n=50000 |
12 |
Correct |
47 ms |
6608 KB |
n=50000 |
13 |
Correct |
28 ms |
3328 KB |
n=10 |
14 |
Correct |
33 ms |
2992 KB |
n=685 |
15 |
Correct |
34 ms |
3280 KB |
n=623 |
16 |
Correct |
18 ms |
2008 KB |
n=973 |
17 |
Correct |
38 ms |
3056 KB |
n=989 |
18 |
Correct |
18 ms |
1252 KB |
n=563 |
19 |
Correct |
30 ms |
1692 KB |
n=592 |
20 |
Correct |
26 ms |
1696 KB |
n=938 |
21 |
Correct |
18 ms |
1480 KB |
n=747 |
22 |
Correct |
20 ms |
1620 KB |
n=991 |
23 |
Execution timed out |
2082 ms |
234944 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |