#include <bits/stdc++.h>
using namespace std;
#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;
void no(){
cout << "-1\n";
exit(0);
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cerr.tie(nullptr);
int n, k;
cin >> n >> k;
set<pi> s;
for (int i = 0; i < n; ++i){
int x;
cin >> x;
s.insert({x, i});
}
vector<vi> sol;
while(!s.empty()){
int len = s.size();
if (len < k) no();
int d = 0;
vi t;
for (int i = 0; i < k; ++i){
pi p = *s.begin();
s.erase(s.begin());
if (!i){
t.push_back(p.first);
d = p.first;
}
t.push_back(p.second+1);
p.first -= d;
if (p.first>0)
s.insert(p);
}
sol.push_back(t);
}
cout << (int)sol.size() << '\n';
for (auto& i : sol){
for (auto& j : i)
cout << j << ' ';
cout << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Incorrect |
1 ms |
364 KB |
Jury has the answer but participant has not |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Incorrect |
1 ms |
364 KB |
Jury has the answer but participant has not |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Incorrect |
1 ms |
364 KB |
Jury has the answer but participant has not |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
769 ms |
77676 KB |
n=1000000 |
2 |
Correct |
454 ms |
59116 KB |
n=666666 |
3 |
Correct |
268 ms |
37008 KB |
n=400000 |
4 |
Incorrect |
166 ms |
22252 KB |
Jury has the answer but participant has not |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Incorrect |
1 ms |
364 KB |
Jury has the answer but participant has not |
3 |
Halted |
0 ms |
0 KB |
- |