Submission #1184950

#TimeUsernameProblemLanguageResultExecution timeMemory
1184950InvMODBaloni (COCI15_baloni)C++17
100 / 100
107 ms3892 KiB
#include<bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;

int mp[N];

int main(){
  int n; cin >> n;

  vector<int> a(n, 0);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  int cnt = 0;
  for(int i = 0; i < n; i++){
    if(!mp[a[i]]){
      mp[a[i] - 1]++;
      cnt++;
    }
    else{
      mp[a[i]]--;
      mp[a[i] - 1]++;
    }
  }

  cout << cnt << "\n";
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...