#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(n) rep1(i,n)
#define rep1(i,n) rep2(i,0,n)
#define rep2(i,a,b) for(int i=a; i<b; ++i)
#define rep3(i,a,b) for(int i=a; i>=b; --i)
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define pow2(x) (1ll<<(x))
#define pii pair<int,int>
#define pb push_back
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x){cerr << x << endl;}
template<typename T, typename ...S> void _do(T && x, S&&... y){cerr << x << ' ',_do(y...);}
#else
#define bug(...) 826
#endif
const int maxn=1000005;
const int mod=1000000007;
int n,k,a[maxn],cur;
vector<vector<int>> res;
signed main(){
ios_base::sync_with_stdio(0),cin.tie(0);
#ifdef i_am_noob
freopen("input1.txt","r",stdin);
freopen("output1.txt","w",stdout);
freopen("output2.txt","w",stderr);
#endif
cin >> n >> k;
rep(n) cin >> a[i];
cur=0;
if(a[0]*n%k){
cout << "-1\n";
return 0;
}
rep(n){
res.pb({0});
rep1(j,k) res.back().pb(cur+1),cur=(cur+1)%n;
if(cur==0) break;
}
for(auto& vec1: res) vec1[0]=a[0]*n/k/sz(res);
cout << sz(res) << "\n";
for(auto& vec1: res){
for(auto i: vec1) cout << i << ' ';
cout << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Not all heaps are empty in the end |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Not all heaps are empty in the end |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Not all heaps are empty in the end |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
453 ms |
57800 KB |
n=1000000 |
2 |
Correct |
251 ms |
29200 KB |
n=666666 |
3 |
Correct |
134 ms |
15516 KB |
n=400000 |
4 |
Correct |
382 ms |
49024 KB |
n=285714 |
5 |
Correct |
6 ms |
876 KB |
n=20000 |
6 |
Correct |
314 ms |
47120 KB |
n=181818 |
7 |
Correct |
3 ms |
588 KB |
n=10000 |
8 |
Correct |
45 ms |
6508 KB |
n=6666 |
9 |
Correct |
2 ms |
492 KB |
n=4000 |
10 |
Correct |
251 ms |
32876 KB |
n=2857 |
11 |
Correct |
1 ms |
364 KB |
n=2000 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Not all heaps are empty in the end |
2 |
Halted |
0 ms |
0 KB |
- |