# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106059 | fadi57 | Karte (COCI18_karte) | C++14 | 268 ms | 13892 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define clr(i, j) memset(i, j, sizeof(i))
#define pb push_back
typedef long long ll;
//-*-*-*-*-*-*-*-*-
#define mod 1000000007
//ll mn[9999];ll mx[9999];ll arr[99999];
map<pair<ll,ll>,ll>mp;
map<ll,ll>m;
ll vis[999999];const int inf = 4e8;
vector<ll>v;vector<ll>f;
//ll inf=9999999;
int main()
{//cout<<8;
ll n,k;cin>>n>>k;ll x;
for(int i=0;i<n;i++){
cin>>x;//if(x>k){l.push_back(x);f++;}else{v.push_back(x);}
v.push_back(x);
}
ll ans[n];
//ll g=upper_bound(v.begin(),v.end(),f)-v.begin();
sort(v.begin(),v.end());ll t=n-1;ll c=0;
for(int i=0;i<n-k;i++){ans[i]=v[i];}ll j=n-k;
for(int i=n-1;i>=n-k;i--){ans[j]=v[i];j++;}
//ll v=0;
for(int i=n-1;i>=0;i--){
if(ans[i]>c){c++;}
}if(c!=k){cout<<-1;return 0;}for(int i=0;i<n;i++){
cout<<ans[i]<<" ";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |