# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
878184 | heeheeheehaaw | Money (IZhO17_money) | C++17 | 1 ms | 2496 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;
int n, aib[1000005];
int v[1000005];
void update(int poz, int val)
{
for(int i = poz; i <= 1000000; i += (i & (-i)))
aib[i] += val;
return;
}
int query(int poz)
{
int sum = 0;
for(int i = poz; i >= 1; i -= (i & (-i)))
sum += aib[i];
return sum;
}
int main()
{
map<int, int> m1, m2;
cin>>n;
for(int i =1 ; i <= n; i++)
cin>>v[i], m1[v[i]] = 1;
/*int cnt = 0;
for(auto it : m1)
m2[it.first] = ++cnt;
for(int i = 1; i <= n; i++)
[i] = m*/
int rez = 1, prev = 0;
for(int i = 1; i <= n; i++)
{
if(v[i] < v[i - 1] || query(v[i]) - query(v[i - 1]) != 0)
rez++;
prev = v[i];
update(v[i], 1);
}
cout<<rez;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |