답안 #367419

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
367419 2021-02-17T08:53:48 Z nicolaalexandra Gift (IZhO18_nicegift) C++14
7 / 100
1348 ms 108784 KB
#include <bits/stdc++.h>
#define DIM 1000010
using namespace std;

set <pair<long long,int> > s;
vector <pair<long long,int> > w;
vector <long long> sol[DIM];
long long v[DIM];
int n,k,i,el;

int main (){

    //ifstream cin ("date.in");
    //ofstream cout ("date.out");

    cin>>n>>k;
    for (i=1;i<=n;i++){
        cin>>v[i];
        s.insert(make_pair(v[i],i));
    }

    while (!s.empty()){
        if (s.size() < k){
            cout<<-1;
            return 0;
        }

        int pas = 0; long long val = 0;
        w.clear();

        for (set <pair<long long,int> > :: reverse_iterator it = s.rbegin(); it != s.rend(); it++){
            //sol[el].push_back(it->second);
            w.push_back(make_pair(it->first,it->second));
            val = it->first;
            pas++;
            if (pas == k)
                break;
        }

        sol[++el].push_back (val);

        for (auto it : w){
            long long x = it.first; int poz = it.second;
            sol[el].push_back(poz);
            s.erase(make_pair(x,poz));
            if (x > val)
                s.insert(make_pair(x-val,poz));
        }
    }

    cout<<el<<"\n";
    for (i=1;i<=el;i++){
        for (auto it : sol[i])
            cout<<it<<" ";
        cout<<"\n";
    }


    return 0;
}

Compilation message

nicegift.cpp: In function 'int main()':
nicegift.cpp:23:22: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |         if (s.size() < k){
      |             ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 23788 KB n=4
2 Correct 17 ms 23788 KB n=3
3 Correct 19 ms 23788 KB n=3
4 Correct 18 ms 23788 KB n=4
5 Correct 17 ms 23788 KB n=4
6 Correct 16 ms 23788 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 23788 KB n=4
2 Correct 17 ms 23788 KB n=3
3 Correct 19 ms 23788 KB n=3
4 Correct 18 ms 23788 KB n=4
5 Correct 17 ms 23788 KB n=4
6 Correct 16 ms 23788 KB n=2
7 Correct 17 ms 23788 KB n=5
8 Correct 16 ms 23788 KB n=8
9 Incorrect 16 ms 23788 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 23788 KB n=4
2 Correct 17 ms 23788 KB n=3
3 Correct 19 ms 23788 KB n=3
4 Correct 18 ms 23788 KB n=4
5 Correct 17 ms 23788 KB n=4
6 Correct 16 ms 23788 KB n=2
7 Correct 17 ms 23788 KB n=5
8 Correct 16 ms 23788 KB n=8
9 Incorrect 16 ms 23788 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1348 ms 108784 KB n=1000000
2 Correct 844 ms 88044 KB n=666666
3 Correct 502 ms 61548 KB n=400000
4 Incorrect 362 ms 47980 KB Jury has the answer but participant has not
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 23788 KB n=4
2 Correct 17 ms 23788 KB n=3
3 Correct 19 ms 23788 KB n=3
4 Correct 18 ms 23788 KB n=4
5 Correct 17 ms 23788 KB n=4
6 Correct 16 ms 23788 KB n=2
7 Correct 17 ms 23788 KB n=5
8 Correct 16 ms 23788 KB n=8
9 Incorrect 16 ms 23788 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -