#include <bits/stdc++.h>
#define maxn 1000010
using namespace std;
int n, k;
int a[maxn];
multiset<pair<int,int>> st;
vector<vector<int> > allIdx;
int main(){
ios_base::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
cin >> n >> k;
for(int i = 0; i < n; ++i){
cin >> a[i];
st.insert({a[i], i} ) ;
}
while(!st.empty()){
allIdx.push_back(vector<int>(k, 0));
auto tmp = st.end();
vector<pair<int, int> > toE;
for(int i = 0; i < k; ++i){
if(tmp == st.begin()){
cout <<-1;
return 0;
}
--tmp;
toE.push_back(*tmp);
allIdx.back()[i] = tmp->second+1;
}
for(auto i : toE){
st.erase(st.find(i));
if(i.first > 1){
st.insert({i.first-1, i.second});
}
}
}
cout << allIdx.size() << '\n';
for(auto i : allIdx){
cout << "1 ";
for(auto j:i){
cout << j << ' ';
}
cout << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
492 KB |
n=5 |
8 |
Correct |
3 ms |
1004 KB |
n=8 |
9 |
Correct |
9 ms |
1212 KB |
n=14 |
10 |
Correct |
6 ms |
1004 KB |
n=11 |
11 |
Correct |
49 ms |
5664 KB |
n=50000 |
12 |
Correct |
52 ms |
5812 KB |
n=50000 |
13 |
Correct |
29 ms |
3488 KB |
n=10 |
14 |
Correct |
31 ms |
3104 KB |
n=685 |
15 |
Correct |
34 ms |
3372 KB |
n=623 |
16 |
Correct |
19 ms |
2084 KB |
n=973 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
492 KB |
n=5 |
8 |
Correct |
3 ms |
1004 KB |
n=8 |
9 |
Correct |
9 ms |
1212 KB |
n=14 |
10 |
Correct |
6 ms |
1004 KB |
n=11 |
11 |
Correct |
49 ms |
5664 KB |
n=50000 |
12 |
Correct |
52 ms |
5812 KB |
n=50000 |
13 |
Correct |
29 ms |
3488 KB |
n=10 |
14 |
Correct |
31 ms |
3104 KB |
n=685 |
15 |
Correct |
34 ms |
3372 KB |
n=623 |
16 |
Correct |
19 ms |
2084 KB |
n=973 |
17 |
Correct |
33 ms |
2596 KB |
n=989 |
18 |
Correct |
15 ms |
1004 KB |
n=563 |
19 |
Correct |
24 ms |
1388 KB |
n=592 |
20 |
Correct |
25 ms |
1516 KB |
n=938 |
21 |
Correct |
19 ms |
1152 KB |
n=747 |
22 |
Correct |
22 ms |
1260 KB |
n=991 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
741 ms |
72192 KB |
Jury has the answer but participant has not |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
492 KB |
n=5 |
8 |
Correct |
3 ms |
1004 KB |
n=8 |
9 |
Correct |
9 ms |
1212 KB |
n=14 |
10 |
Correct |
6 ms |
1004 KB |
n=11 |
11 |
Correct |
49 ms |
5664 KB |
n=50000 |
12 |
Correct |
52 ms |
5812 KB |
n=50000 |
13 |
Correct |
29 ms |
3488 KB |
n=10 |
14 |
Correct |
31 ms |
3104 KB |
n=685 |
15 |
Correct |
34 ms |
3372 KB |
n=623 |
16 |
Correct |
19 ms |
2084 KB |
n=973 |
17 |
Correct |
33 ms |
2596 KB |
n=989 |
18 |
Correct |
15 ms |
1004 KB |
n=563 |
19 |
Correct |
24 ms |
1388 KB |
n=592 |
20 |
Correct |
25 ms |
1516 KB |
n=938 |
21 |
Correct |
19 ms |
1152 KB |
n=747 |
22 |
Correct |
22 ms |
1260 KB |
n=991 |
23 |
Incorrect |
741 ms |
72192 KB |
Jury has the answer but participant has not |
24 |
Halted |
0 ms |
0 KB |
- |