Submission #40397

#TimeUsernameProblemLanguageResultExecution timeMemory
40397szawinisKarte (COCI18_karte)C++14
120 / 120
175 ms12304 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5e5+1; int n, k, a[N]; int main() { scanf("%d %d", &n, &k); for(int i = 0; i < n; i++) scanf("%d", a+i); sort(a, a+n, greater<int>()); reverse(a, a+k); reverse(a+k, a+n); int cnt = 0; for(int i = 0; i < n; i++) cnt += cnt < a[i]; if(cnt != k) printf("-1"); else { reverse(a, a+n); for(int i = 0; i < n; i++) printf("%d ", a[i]); } }

Compilation message (stderr)

karte.cpp: In function 'int main()':
karte.cpp:7:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &k);
                        ^
karte.cpp:8:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i < n; i++) scanf("%d", a+i);
                                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...