Submission #137410

# Submission time Handle Problem Language Result Execution time Memory
137410 2019-07-27T16:56:44 Z vardan__02 Gift (IZhO18_nicegift) C++14
0 / 100
1667 ms 22728 KB
#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+n;
                cout<<m<<endl;
                v=a[n]/k;
                for(i=1;i<=n;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 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1667 ms 22728 KB n=1000000
2 Correct 824 ms 13660 KB n=666666
3 Correct 342 ms 7456 KB n=400000
4 Incorrect 1132 ms 13348 KB Taken too much stones from the heap
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -