#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
ll n,k,a[1000005],m,i,j,p,q,t,u,v;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>k;
for(i=1;i<=n;i++)
{
cin>>a[i];
if(a[i]!=a[1])
t=1;
}
if(t==0)
{
if(n%k!=0)
{
if(a[1]%k!=0)
cout<<-1<<endl;
else
{
p=k+n%k;
m=n/k-1+p;
cout<<m<<endl;
v=a[n]/k;
for(i=1;i<=p;i++)
{
cout<<v<<" ";
q=k;
u=a[p];
j=1;
while(a[j]!=u)
j++;
while(j<=p && q!=0)
{
a[j]-=v;
cout<<j<<" ";
j++;
q--;
}
if(q!=0)
{
u=a[p];
j=1;
while(a[j]!=u)
j++;
while(q!=0 && j<=p)
{
a[j]-=v;
cout<<j<<" ";
j++;
q--;
}
}
cout<<endl;
}
for(i=p+1;i<=n;i++)
{
if((i-p)%k==1)
cout<<a[n]<<" ";
cout<<i<<" ";
if((i-p)%k==0)
cout<<endl;
}
}
}
else
{
cout<<n/k<<endl;
cout<<a[1]<<" ";
for(i=1;i<=n;i++)
{
cout<<i<<" ";
if(i%k==0)
{
cout<<endl;
if(i!=n)
cout<<a[1]<<" ";
}
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
380 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
380 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
380 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1660 ms |
22652 KB |
n=1000000 |
2 |
Correct |
821 ms |
13400 KB |
n=666666 |
3 |
Correct |
350 ms |
7628 KB |
n=400000 |
4 |
Correct |
206 ms |
5092 KB |
n=285714 |
5 |
Correct |
9 ms |
888 KB |
n=20000 |
6 |
Correct |
105 ms |
5752 KB |
n=181818 |
7 |
Correct |
5 ms |
632 KB |
n=10000 |
8 |
Incorrect |
4 ms |
504 KB |
Jury has the answer but participant has not |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
380 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |