# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
374078 | Nimbostratus | Baloni (COCI15_baloni) | C++17 | 238 ms | 32108 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define clean(a,s) memset((a),0,sizeof((a)[0])*(s))
#define all(x) (x).begin() , (x).end()
#define fi first
#define se second
#define int int
using pii = pair<int,int>;
using ll = long long;
const int maxn = 1e6+5;
const int inf = 2e9;
const int mod = 1e9+7;
int n,a[maxn],ans;
vector<int> occ[maxn];
int32_t main () {
//freopen("in","r",stdin); freopen("out","w",stdout);
ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
cin >> n;
for(int i=1;i<=n;i++) cin >> a[i] , occ[a[i]].pb(i);
ans = 1;
for(int i=2;i<=n;i++) {
int pos = lb(all(occ[a[i]+1]),i)-occ[a[i]+1].begin()-1;
if(pos == -1 || pos >= occ[a[i]+1].size()) {
ans++;
continue;
};
pos = occ[a[i]+1][pos];
if(*lb(all(occ[a[i]]),pos) < i) ans++;
}
cout << ans << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |