Submission #49738

#TimeUsernameProblemLanguageResultExecution timeMemory
49738IvanCKarte (COCI18_karte)C++17
120 / 120
188 ms10612 KiB
#include <bits/stdc++.h> using namespace std; vector<int> V,U; int N,K,F,copia; int main(){ scanf("%d %d",&N,&K); copia = K; for(int i = 1;i<=N;i++){ int a; scanf("%d",&a); V.push_back(a); } sort(V.begin(),V.end()); while(copia > 0){ if(V.empty()){ printf("-1\n"); return 0; } copia--; U.push_back(V.back()); V.pop_back(); } reverse(U.begin(),U.end()); for(int i : V){ U.push_back(i); } for(int i : U){ if(F < i){ F++; } } if(F != K) printf("-1\n"); else{ reverse(U.begin(),U.end()); for(int i : U) printf("%d ",i); printf("\n"); } return 0; }

Compilation message (stderr)

karte.cpp: In function 'int main()':
karte.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&N,&K);
  ~~~~~^~~~~~~~~~~~~~~
karte.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a);
   ~~~~~^~~~~~~~~
#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...