답안 #139291

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
139291 2019-07-31T14:10:40 Z mechfrog88 Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
1000 ms 57316 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld; 
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    list <pair<ll,ll>> arr;
    vector <ll> ori;
    vector <ll> num(30,0);
    ll mini = 30;
    for (int z=0;z<n;z++){
        ll temp;
        cin >> temp;
        num[temp]++;
        mini = min(temp,mini);
        arr.push_back(make_pair(temp,z));
        ori.push_back(temp);
    }
    for (auto it = arr.begin();it != arr.end();){
        auto ita = it;
        ita++;
        if (it->first == ita->first && ita->first == mini){
            arr.insert(it,make_pair(it->first+1,it->second));
            arr.erase(it);
            arr.erase(ita);
            it = arr.begin();
            num[mini]-=2;
            num[mini+1]++;
            if (num[mini] == 0){
                mini++;
            }
        } else {
            it++;
        }
        // for (auto itq = arr.begin();itq != arr.end();itq++){
        //     cout << itq->first << " ";
        // } cout << endl;
    }
    ll i = 0;
    ll q = 0;
    arr.push_back(make_pair(LLONG_MAX,0));
    for (auto it = arr.begin();it != arr.end();it++){
        if (it->first == mini){
            i = it->second;
            q = it->first;
            break;
        }
    }
    for (int z=0;z<n;z++){
        if (z == i) cout << q << " ";
        cout << ori[z] << " ";
    }
    cout << endl;
}

// 29 29
// 28 28 28 28
// 28 27 27 28 27 27
// 28 27 26 28 27 25 25 26
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1063 ms 57224 KB Time limit exceeded
2 Execution timed out 1073 ms 57040 KB Time limit exceeded
3 Execution timed out 1070 ms 57120 KB Time limit exceeded
4 Execution timed out 1052 ms 57052 KB Time limit exceeded
5 Execution timed out 1079 ms 57040 KB Time limit exceeded
6 Execution timed out 1063 ms 57112 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1089 ms 57152 KB Time limit exceeded
2 Execution timed out 1076 ms 57040 KB Time limit exceeded
3 Execution timed out 1083 ms 56912 KB Time limit exceeded
4 Execution timed out 1092 ms 57044 KB Time limit exceeded
5 Execution timed out 1084 ms 57168 KB Time limit exceeded
6 Execution timed out 1083 ms 57072 KB Time limit exceeded
7 Execution timed out 1075 ms 57044 KB Time limit exceeded
8 Execution timed out 1074 ms 57316 KB Time limit exceeded
9 Execution timed out 1073 ms 45776 KB Time limit exceeded
10 Execution timed out 1077 ms 17380 KB Time limit exceeded
11 Execution timed out 1081 ms 28764 KB Time limit exceeded
12 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
13 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
14 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected