# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84081 | 2018-11-12T20:00:06 Z | wzy | Karte (COCI18_karte) | C++11 | 157 ms | 7976 KB |
#include <bits/stdc++.h> using namespace std; int n , k; int32_t main(){ scanf("%d%d" , &n , &k); vector<int> big , small; for(int i = 0 ; i < n; i ++){ int x; scanf("%d" , &x); if(x > k) big.push_back(x); else small.push_back(x); } sort(big.begin() , big.end()); sort(small.begin() , small.end()); if(big.size() > k){ puts("-1"); return 0; } else if(big.size() == k){ vector<int> t; for(auto w : big) t.push_back(w); for(auto w : small) t.push_back(w); reverse(t.begin() , t.end()); int fs = 0; for(auto w : t){ if(w <= fs) continue; else fs++; } if(fs == k) for(auto w : t){ printf("%d " , w); } else puts("-1"); } else if(big.size() < k){ int u = k; u-= (int) big.size(); vector<int> pick; int fs = 0; for(auto &w : small){ if(u == 0) break; if(w <= fs){ continue; } else pick.push_back(w) , fs++ , u-- , w = -1; } if(u>0){ puts("-1"); return 0; } for(auto w : big){ pick.push_back(w); } for(auto w : small){ if(w == -1) continue; pick.push_back(w); } fs = 0; bool can = true; for(auto w : pick){ if(w <= fs) continue; else fs++; } if(fs == k){ reverse(pick.begin() , pick.end()); for(auto w : pick) printf("%d " , w ); } else puts("-1"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 448 KB | Output is correct |
2 | Correct | 2 ms | 456 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 484 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 568 KB | Output is correct |
2 | Correct | 3 ms | 748 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 748 KB | Output is correct |
2 | Correct | 2 ms | 748 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 748 KB | Output is correct |
2 | Correct | 3 ms | 748 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 748 KB | Output is correct |
2 | Correct | 2 ms | 748 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 2700 KB | Output is correct |
2 | Correct | 32 ms | 2700 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 65 ms | 3988 KB | Output is correct |
2 | Correct | 47 ms | 3988 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 157 ms | 7976 KB | Output is correct |
2 | Correct | 102 ms | 7976 KB | Output is correct |