Submission #578690

#TimeUsernameProblemLanguageResultExecution timeMemory
578690Trisanu_DasBaloni (COCI15_baloni)C++17
100 / 100
228 ms3712 KiB
#include <bits/stdc++.h>
using namespace std;
#define H 1000001

int a[H], cnt[H];

int main(){
  int n; cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  for(int i = n - 1; i > -1; i--){
    cnt[a[i]]++;
    if(cnt[a[i] - 1]) cnt[a[i] - 1]--; else ans++;
  }
  cout << ans << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...