답안 #106059

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
106059 2019-04-16T10:30:03 Z fadi57 Karte (COCI18_karte) C++14
120 / 120
268 ms 13892 KB
#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

karte.cpp: In function 'int main()':
karte.cpp:32:36: warning: unused variable 't' [-Wunused-variable]
         sort(v.begin(),v.end());ll t=n-1;ll c=0;
                                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 3180 KB Output is correct
2 Correct 40 ms 2540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 114 ms 5844 KB Output is correct
2 Correct 102 ms 4908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 268 ms 13892 KB Output is correct
2 Correct 212 ms 11228 KB Output is correct