# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143186 | 2019-08-13T09:59:33 Z | Shelby | Karte (COCI18_karte) | C++11 | 33 ms | 2284 KB |
#include <bits/stdc++.h> #define MAXN 100000 using namespace std; int a[MAXN],ans[MAXN]; vector<int> sol; vector<int> v; 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); cnt=0; for(i=0;i<n;i++) { if(a[i]>cnt) { cnt++; sol.push_back(a[i]); } else v.push_back(a[i]); } //reverse(sol.begin(),sol.end()); //for(i=0;i<sol.size();i++) printf("%d ",sol[i]); cnt--; if(k<=sol.size()) { int l=0,r=sol.size()-1; dif=sol.size()-k; while(l<r && dif!=0) { if(sol[l]<=cnt) { swap(sol[l],sol[r]); cnt--; dif--; } l++; r--; if(dif==0) break; } //cout << dif; if(dif!=0) printf("-1\n"); else { for(i=0;i<v.size();i++) printf("%d ",v[i]); reverse(sol.begin(),sol.end()); for(i=0;i<sol.size();i++) printf("%d ",sol[i]); } } else printf("-1\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | 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 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | 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 | 3 ms | 380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 2284 KB | Output is correct |
2 | Correct | 25 ms | 1948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 16 ms | 1656 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 16 ms | 1616 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |