답안 #568590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
568590 2022-05-25T18:36:14 Z urosk Zalmoxis (BOI18_zalmoxis) C++14
20 / 100
137 ms 10996 KB
// __builtin_popcount(x)
// __builtin_popcountll(x)
#define here cerr<<"===========================================\n"
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
using namespace std;

#define maxn 1000005
ll n,k;
vector<ll> v;
ll a[maxn];
int main(){
	ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
    cin >> n >> k;
    bool bio = 0;
    ll last = -1;
    ll e = -1;
    for(ll i = 1;i<=n;i++){
        cin >> a[i];
        ll x = a[i];
        v.pb(x);
        while(sz(v)>1&&v[sz(v)-1]==v[sz(v)-2]){
            ll x = v.back()+1;
            v.popb();
            v.popb();
            v.pb(x);
            last = i;
            e = x;
            bio = 1;
        }

    }
    if(bio){
        if(sz(v)==1){
            for(ll i = 1;i<=n;i++) cout<<a[i]<< " ";
            cout<<v[0]<<endl;
            return 0;
        }
        for(ll i = 1;i<=n;i++){
            cout<<a[i]<< " ";
            if(last==i){
                cout<<e<< " ";
            }
        }
        cout<<endl;
    }else{
        ll mn = llinf;
        for(ll i = 1;i<=n;i++) mn = min(mn,a[i]);
        for(ll i = 1;i<=n;i++){
            cout<<a[i]<< " ";
            if(a[i]==mn&&k>0){
                cout<<mn<< " ";
                k--;
            }
        }
        cout<<endl;
    }
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 10732 KB Output is correct
2 Correct 124 ms 10712 KB Output is correct
3 Correct 137 ms 10692 KB Output is correct
4 Incorrect 124 ms 10744 KB not a zalsequence
5 Incorrect 125 ms 10708 KB not a zalsequence
6 Correct 129 ms 10636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 137 ms 10656 KB Unexpected end of file - int32 expected
2 Incorrect 124 ms 10924 KB Unexpected end of file - int32 expected
3 Incorrect 135 ms 10936 KB Unexpected end of file - int32 expected
4 Incorrect 122 ms 10740 KB Unexpected end of file - int32 expected
5 Incorrect 133 ms 10660 KB Unexpected end of file - int32 expected
6 Incorrect 127 ms 10744 KB Unexpected end of file - int32 expected
7 Incorrect 125 ms 10764 KB Unexpected end of file - int32 expected
8 Incorrect 125 ms 10804 KB Unexpected end of file - int32 expected
9 Incorrect 104 ms 10996 KB Unexpected end of file - int32 expected
10 Incorrect 48 ms 5140 KB Unexpected end of file - int32 expected
11 Incorrect 60 ms 8512 KB Unexpected end of file - int32 expected
12 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
13 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
14 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected