Submission #103943

#TimeUsernameProblemLanguageResultExecution timeMemory
103943MrTEKZalmoxis (BOI18_zalmoxis)C++14
30 / 100
179 ms7776 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e6 + 5;
const int inf = 1e9;

vector <ii> v;
int n,k,a[N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> k;
  for (int i = 1 ; i <= n ; i++)
    cin >> a[i];
  for (int i = 1 ; i <= n ; i++) {
    int x = a[i],tut = i;
    while(v.empty() == false && v.back().first == x) {     
      tut = v.back().second;
      v.pop_back();
      x++;
    }
    v.push_back({x,tut});
  }
  int mn = inf,tut;
  for (auto i : v) {
    if (i.first < mn) {
      mn = i.first;
      tut = i.second;
    }
  }
  for (int i = 1 ; i <= n ; i++) {
    if (tut == i)
      cout << mn << " ";
    cout << a[i] << " ";
  }
}

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:37:5: warning: 'tut' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if (tut == i)
     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...