Submission #168320

#TimeUsernameProblemLanguageResultExecution timeMemory
168320aydinenesKarte (COCI18_karte)C++11
120 / 120
343 ms9988 KiB
#include<bits/stdc++.h> #define mid(l,r) ((l+r)/2) using namespace std; const int N = 1e6 + 7; const int inf = 1e9 + 7; int n, k; vector<int> v; vector<int> ans; int main(){ cin >> n >> k; for(int i = 0; i < n; i++){ int t; cin >> t; v.push_back(t); } sort(v.begin(), v.end()); for(int i = n - k; i < n; i++){ if(v[i] <= ans.size()){ cout << "-1"; return 0; } ans.push_back(v[i]); } for(int i = 0; i < n - k; i++){ if(v[i] > k){ cout << "-1"; return 0; } ans.push_back(v[i]); } for(int i = ans.size() - 1; i >= 0; i--){ cout << ans[i] << " "; } }

Compilation message (stderr)

karte.cpp: In function 'int main()':
karte.cpp:28:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(v[i] <= ans.size()){
#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...