#include <bits/stdc++.h>
using namespace std;
using tint = long long;
using ld = long double;
#define forsn(i, s, n) for(int i = s; i < int(n); i++)
#define forn(i, n) forsn(i, 0, n)
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
#define DBG(x) cerr << #x << " = " << x << endl;
const int MOD = 1e9+7;
const int MX = 1e5+5;
const tint INF = 2e18;
const int inf = 2e9;
const ld PI = acos(ld(-1));
void NACHO(string name = "moop"){
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen((name+".in").c_str(), "r", stdin);
// freopen((name+".in").c_str(), "w", stdout);
}
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
bool valid(int x, int y, int n, int m){
return (0<=x && x<n && 0<=y && y<m);
}
int main(){
NACHO();
int n; cin >> n;
vi a (n);
forn(i, n) cin >> a[i];
vector<bool> seen (1e6+1, 0);
int ret = 0;
for(int i=n-1;i>=0;--i){
seen[a[i]]=1;
if(!seen[a[i]-1]) ++ret;
}
cout << ret << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
524 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
620 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
620 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
620 KB |
Output isn't correct |
5 |
Incorrect |
71 ms |
7136 KB |
Output isn't correct |
6 |
Incorrect |
74 ms |
7524 KB |
Output isn't correct |
7 |
Incorrect |
61 ms |
6116 KB |
Output isn't correct |
8 |
Incorrect |
63 ms |
6244 KB |
Output isn't correct |
9 |
Incorrect |
67 ms |
6660 KB |
Output isn't correct |
10 |
Incorrect |
70 ms |
6756 KB |
Output isn't correct |