Submission #103942

#TimeUsernameProblemLanguageResultExecution timeMemory
103942MrTEKZalmoxis (BOI18_zalmoxis)C++14
0 / 100
250 ms14724 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++) {
    if (v.empty() == false && v.back().first == a[i]) {
      int tut = v.back().second;
      v.pop_back();
      v.push_back({a[i] + 1,tut});
    }
    else {
      v.push_back({a[i],i});
    }
  }
  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:38: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...