답안 #568608

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
568608 2022-05-25T19:28:49 Z urosk Zalmoxis (BOI18_zalmoxis) C++14
30 / 100
187 ms 14600 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<pll> 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,i});
        while(sz(v)>1&&v[sz(v)-1].fi==v[sz(v)-2].fi){
            ll x = v.back().fi+1;
            v.popb();
            v.popb();
            v.pb({x,i});
            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].fi<<endl;
            return 0;
        }
        if(v[0].fi<v[1].fi){
            cout<<v[0].fi<<" ";
            for(ll i = 1;i<=n;i++) cout<<a[i]<<" ";
            cout<<endl;
        }else{
            for(ll j = 0;j+1<sz(v);j++){
                if(v[j].fi<v[j+1].fi){
                    for(ll i = 1;i<=n;i++){
                        cout<<a[i]<< " ";
                        if(i==v[j].sc) cout<<v[j].fi<<  " ";
                    }
                    cout<<endl;
                    return 0;
                }
            }
            for(ll i = 1;i<=n;i++) cout<<a[i]<< " ";
            cout<<v.back().fi<<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;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:31:8: warning: variable 'last' set but not used [-Wunused-but-set-variable]
   31 |     ll last = -1;
      |        ^~~~
zalmoxis.cpp:32:8: warning: variable 'e' set but not used [-Wunused-but-set-variable]
   32 |     ll e = -1;
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 152 ms 11368 KB Output is correct
2 Correct 170 ms 11212 KB Output is correct
3 Correct 151 ms 11212 KB Output is correct
4 Correct 153 ms 11184 KB Output is correct
5 Correct 175 ms 11156 KB Output is correct
6 Correct 158 ms 11140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 187 ms 11212 KB Unexpected end of file - int32 expected
2 Incorrect 151 ms 11600 KB Unexpected end of file - int32 expected
3 Incorrect 182 ms 11772 KB Unexpected end of file - int32 expected
4 Incorrect 169 ms 11192 KB Unexpected end of file - int32 expected
5 Incorrect 163 ms 11200 KB Unexpected end of file - int32 expected
6 Incorrect 152 ms 11224 KB Unexpected end of file - int32 expected
7 Incorrect 157 ms 11256 KB Unexpected end of file - int32 expected
8 Incorrect 162 ms 11200 KB Unexpected end of file - int32 expected
9 Incorrect 116 ms 14600 KB Unexpected end of file - int32 expected
10 Incorrect 43 ms 7096 KB Unexpected end of file - int32 expected
11 Incorrect 74 ms 13116 KB Unexpected end of file - int32 expected
12 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
13 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
14 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected