Submission #143200

# Submission time Handle Problem Language Result Execution time Memory
143200 2019-08-13T10:46:50 Z Shelby Karte (COCI18_karte) C++11
96 / 120
32 ms 1340 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=n-1;i>=0;i--)
    {
        if(a[i]>=br)
        {
            an++;

            br++;
        }
    }

    return an;
}

void ispisi(int n)
{
    for(int i=0;i<n;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 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1272 KB Output is correct
2 Correct 23 ms 1340 KB Output is correct
# 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 -
# 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 -