Submission #92761

# Submission time Handle Problem Language Result Execution time Memory
92761 2019-01-04T13:07:23 Z Vardanyan Gift (IZhO18_nicegift) C++14
7 / 100
2000 ms 8196 KB
#include<bits/stdc++.h>

using namespace std;
const int N = 1000*1000+5;
pair<int,int> a[N];

int main()   {
    int n,k;
    scanf("%d%d",&n,&k);
    int sum = 0;
    for(int i = 1;i<=n;i++){
            scanf("%d",&a[i].first);
            a[i].second = i;
            sum+=a[i].first;
    }
    sort(a+1,a+1+n);
    vector<vector<int> > ans;
    while(1){
        int kk = k;
        vector<int> now;
        for(int i = n;i>=1;i--){
            if(a[i].first<=0){
                printf("-1\n");
                return 0;
            }
            a[i].first--;
            sum--;
            now.push_back(a[i].second);
            kk--;
            if(kk == 0) break;
        }
        ans.push_back(now);
        if(sum == 0) break;
        sort(a+1,a+1+n);
    }
    printf("%d\n",ans.size());
    for(int i = 0;i<ans.size();i++){
        printf("1 ");
        for(int j = 0;j<ans[i].size();j++){
            printf("%d ",ans[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Compilation message

nicegift.cpp: In function 'int main()':
nicegift.cpp:36:29: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<std::vector<int> >::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",ans.size());
                   ~~~~~~~~~~^
nicegift.cpp:37:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<ans.size();i++){
                   ~^~~~~~~~~~~
nicegift.cpp:39:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0;j<ans[i].size();j++){
                       ~^~~~~~~~~~~~~~
nicegift.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
nicegift.cpp:12:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&a[i].first);
             ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB n=4
2 Correct 2 ms 376 KB n=3
3 Correct 2 ms 376 KB n=3
4 Correct 2 ms 376 KB n=4
5 Correct 2 ms 256 KB n=4
6 Correct 2 ms 376 KB n=2
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB n=4
2 Correct 2 ms 376 KB n=3
3 Correct 2 ms 376 KB n=3
4 Correct 2 ms 376 KB n=4
5 Correct 2 ms 256 KB n=4
6 Correct 2 ms 376 KB n=2
7 Correct 2 ms 256 KB n=5
8 Correct 4 ms 1016 KB n=8
9 Correct 7 ms 1200 KB n=14
10 Correct 5 ms 1016 KB n=11
11 Execution timed out 2056 ms 1248 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB n=4
2 Correct 2 ms 376 KB n=3
3 Correct 2 ms 376 KB n=3
4 Correct 2 ms 376 KB n=4
5 Correct 2 ms 256 KB n=4
6 Correct 2 ms 376 KB n=2
7 Correct 2 ms 256 KB n=5
8 Correct 4 ms 1016 KB n=8
9 Correct 7 ms 1200 KB n=14
10 Correct 5 ms 1016 KB n=11
11 Execution timed out 2056 ms 1248 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 155 ms 8196 KB Jury has the answer but participant has not
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB n=4
2 Correct 2 ms 376 KB n=3
3 Correct 2 ms 376 KB n=3
4 Correct 2 ms 376 KB n=4
5 Correct 2 ms 256 KB n=4
6 Correct 2 ms 376 KB n=2
7 Correct 2 ms 256 KB n=5
8 Correct 4 ms 1016 KB n=8
9 Correct 7 ms 1200 KB n=14
10 Correct 5 ms 1016 KB n=11
11 Execution timed out 2056 ms 1248 KB Time limit exceeded
12 Halted 0 ms 0 KB -