# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
35150 | Pajaraja | Money (IZhO17_money) | C++14 | 303 ms | 9828 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 bit[1000007],a[1000007],n;
void upd(int x)
{
while(x<=1000000)
{
bit[x]++;
x+=(x&-x);
}
}
int sum(int x)
{
int s=0;
while(x>0)
{
s+=bit[x];
x-=(x&-x);
}
return s;
}
bool ima(int l,int r) {return sum(r-1)>sum(l);}
int main()
{
int cnt=1,last=0;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%d",&a[i]);
for(int i=1;i<n;i++)
{
if(a[i]<a[i-1] || ima(a[last],a[i]))
{
cnt++;
while(last<i) upd(a[last++]);
}
}
printf("%d",cnt);
}
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... |