# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99515 | rzbt | Money (IZhO17_money) | C++14 | 344 ms | 11160 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>
#define MAXN 1000006
using namespace std;
int n;
int bit[MAXN];
vector<int> niz;
void dodaj(int p,int x){
for(;p<MAXN;p+=(-p)&p)
bit[p]+=x;
}
int dobij(int p){
int z=0;
for(;p>0;p-=(-p)&p)
z+=bit[p];
return z;
}
int res=0;
int main()
{
scanf("%d", &n);
for(int i=1;i<=n;i++){
int t;
scanf("%d", &t);
if(niz.empty()){
niz.push_back(t);
res=1;
continue;
}
if(t<niz.back() || dobij(t-1)>dobij(niz[0])){
res++;
for(auto x:niz)dodaj(x,1);
niz.clear();
niz.push_back(t);
}else{
niz.push_back(t);
}
}
printf("%d",res);
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... |