답안 #89519

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
89519 2018-12-15T07:59:08 Z Harvey_Rollens Gift (IZhO18_nicegift) C++14
7 / 100
1890 ms 93040 KB
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define st string
#define fr first
#define se second

const ll mod=1e9+7;

using namespace std;

set<pair<ll, ll> > a;
vector<pair<ll, vector<ll> > > v;

int main()
{
    //freopen("1.txt", "r", stdin);
    //freopen("1.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n, k, s=0;
    cin>>n>>k;

    for(ll i=1; i<=n; i++)
    {
        ll x;
        cin>>x;
        a.insert({x, i});
        s+=x;
    }

    if(s%k!=0)
    {
        cout<<-1;
        return 0;
    }

    while(a.size()>=k)
    {

        std::vector<ll> q;
        std::vector<pair<ll, ll> > y;

        for(ll i=1; i<=k; i++)
        {
            //cout<<i<<" "<<a.size()<<endl;
            std::pair<ll, ll> x;

            x=*a.rbegin();
            a.erase(*a.rbegin());

            q.push_back(x.se);
            y.push_back(x);
        }

        ll z=y[y.size()-1].fr;
        for(ll i=0; i<y.size(); i++)
        {
            y[i].fr-=z;
            if(y[i].fr) a.insert(y[i]);
            //cout<<"y="<<y[i].fr<<" "<<y[i].se<<endl;
        }

        v.push_back({z, q});
    }

    if(a.size()>0)
    {
        cout<<-1;
        return 0;
    }

    cout<<v.size()<<endl;
    for(ll i=0; i<v.size(); i++)
    {
        cout<<v[i].fr<<" ";
        for(ll j=0; j<v[i].se.size(); j++)
        {
            cout<<v[i].se[j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}
/*
*/

Compilation message

nicegift.cpp: In function 'int main()':
nicegift.cpp:40:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(a.size()>=k)
           ~~~~~~~~^~~
nicegift.cpp:59:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(ll i=0; i<y.size(); i++)
                     ~^~~~~~~~~
nicegift.cpp:76:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll i=0; i<v.size(); i++)
                 ~^~~~~~~~~
nicegift.cpp:79:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(ll j=0; j<v[i].se.size(); j++)
                     ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB n=4
2 Correct 2 ms 372 KB n=3
3 Correct 2 ms 452 KB n=3
4 Correct 2 ms 524 KB n=4
5 Correct 2 ms 644 KB n=4
6 Correct 2 ms 644 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB n=4
2 Correct 2 ms 372 KB n=3
3 Correct 2 ms 452 KB n=3
4 Correct 2 ms 524 KB n=4
5 Correct 2 ms 644 KB n=4
6 Correct 2 ms 644 KB n=2
7 Correct 2 ms 644 KB n=5
8 Correct 2 ms 644 KB n=8
9 Incorrect 2 ms 716 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB n=4
2 Correct 2 ms 372 KB n=3
3 Correct 2 ms 452 KB n=3
4 Correct 2 ms 524 KB n=4
5 Correct 2 ms 644 KB n=4
6 Correct 2 ms 644 KB n=2
7 Correct 2 ms 644 KB n=5
8 Correct 2 ms 644 KB n=8
9 Incorrect 2 ms 716 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1890 ms 93040 KB n=1000000
2 Correct 1043 ms 93040 KB n=666666
3 Correct 535 ms 93040 KB n=400000
4 Incorrect 241 ms 93040 KB Jury has the answer but participant has not
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB n=4
2 Correct 2 ms 372 KB n=3
3 Correct 2 ms 452 KB n=3
4 Correct 2 ms 524 KB n=4
5 Correct 2 ms 644 KB n=4
6 Correct 2 ms 644 KB n=2
7 Correct 2 ms 644 KB n=5
8 Correct 2 ms 644 KB n=8
9 Incorrect 2 ms 716 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -