Submission #143843

#TimeUsernameProblemLanguageResultExecution timeMemory
143843MladenPMoney (IZhO17_money)C++17
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #define MAXN 1000010 #define PRINT(x) cerr<<#x<<'='<<x<<endl; using namespace std; int a[MAXN], bit[MAXN], N, n, rez; int query(int idx) { int rez = 0; for( ; idx ; idx -= idx&-idx) rez += bit[idx]; return rez; } void update(int idx, int val) { for( ; idx < MAXN; idx += idx&-idx) bit[idx] += val; } int main() { cin >> n; N = 1; for(int i = 1; i <= n; i++) { cin >> a[N]; if(a[N] != a[N-1]) N++; } N--; rez = 1; for(int i = 2; i <= N; i++) { if(a[i-1] > a[i] || query(a[i]-1) > query(a[i-1]-1)) { rez++; } update(a[i-1], +1); } cout << rez; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...