# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83851 | 2018-11-11T11:35:21 Z | nikolapesic2802 | Karte (COCI18_karte) | C++14 | 534 ms | 28732 KB |
/* - Keep a variable k- how many cards need to be wrong until the end. */ #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back int main() { int n,k; scanf("%i %i",&n,&k); int t=k; multiset<int> karte; karte.insert(INT_MAX); for(int i=0;i<n;i++) { int a; scanf("%i",&a); karte.insert(a); } vector<int> sol; for(int i=0;i<n;i++) { int a=*karte.lower_bound(k); if(a==INT_MAX) { a=*karte.begin(); } sol.pb(a); karte.erase(karte.find(a)); if(a!=k) k--; continue; } int cnt=0; for(int i=n-1;i>=0;i--) { if(sol[i]<=cnt) continue; cnt++; } if(cnt==t) { for(int i=0;i<n;i++) { printf("%i ",sol[i]); } } else { printf("-1"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 508 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 508 KB | Output is correct |
2 | Correct | 2 ms | 508 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 508 KB | Output is correct |
2 | Correct | 2 ms | 524 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 532 KB | Output is correct |
2 | Correct | 2 ms | 660 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 668 KB | Output is correct |
2 | Correct | 3 ms | 668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 668 KB | Output is correct |
2 | Correct | 3 ms | 668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 668 KB | Output is correct |
2 | Correct | 3 ms | 668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 6344 KB | Output is correct |
2 | Correct | 84 ms | 6344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 193 ms | 11884 KB | Output is correct |
2 | Correct | 190 ms | 11884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 534 ms | 28732 KB | Output is correct |
2 | Correct | 491 ms | 28732 KB | Output is correct |