#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e12;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<pair<int,int>> arr(n);
int tot = 0;
for(int i=0;i<n;i++){cin>>arr[i].first;tot+=arr[i].first;arr[i].second=i+1;}
vector<int> limits(tot+1,INF);
sort(arr.rbegin(),arr.rend());
auto carr = arr;
vector<int> cookies = {-1};
for(auto&[a,b]:arr){
while(a){
cookies.emplace_back(b);
a--;
}
}
int m;
cin >> m;
vector<int> weights(m);
for(int&i:weights)cin>>i;
if(tot%weights[0]){
cout << "-1\n";
return 0;
}
bool works = true;
for(auto&[a,b]:carr){
if(a>tot/weights[0])works=false;
}
if(!works){
cout << "-1\n";
return 0;
}
cout << tot/weights[0] << '\n';
for(int i=1;i<=tot/weights[0];i++){
cout << weights[0] << ' ';
for(int j=i;j<=tot;j+=tot/weights[0]){
cout << cookies[j] << ' ';
}
cout << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
712 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
860 KB |
Output is correct |
19 |
Correct |
2 ms |
860 KB |
Output is correct |
20 |
Correct |
1 ms |
860 KB |
Output is correct |
21 |
Correct |
1 ms |
1112 KB |
Output is correct |
22 |
Correct |
1 ms |
860 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |