Submission #143199

# Submission time Handle Problem Language Result Execution time Memory
143199 2019-08-13T10:45:25 Z Shelby Karte (COCI18_karte) C++11
0 / 120
23 ms 760 KB
#include <bits/stdc++.h>
#define MAXN 100000
using namespace std;

int a[MAXN];

int check(int n)
{
    int br=0,an=0;

    for(int i=0;i<n;i++)
    {
        if(a[i]>=br)
        {
            an++;

            br++;
        }
    }

    return an;
}

void ispisi(int n)
{
    for(int i=n-1;i>0;i--) printf("%d ",a[i]);
}

int main()
{ int n,i,k,cnt,dif;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++) scanf("%d",&a[i]);

sort(a,a+n);

reverse(a+n-k,a+n);

dif=check(n);

if(dif!=k) printf("-1\n");
else ispisi(n);
    return 0;
}

Compilation message

karte.cpp: In function 'int main()':
karte.cpp:30:13: warning: unused variable 'cnt' [-Wunused-variable]
 { int n,i,k,cnt,dif;
             ^~~
karte.cpp:31:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d%d",&n,&k);
 ~~~~~^~~~~~~~~~~~~~
karte.cpp:32:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 for(i=0;i<n;i++) scanf("%d",&a[i]);
                  ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 16 ms 632 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 16 ms 760 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -