# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88793 | asifthegreat | Baloni (COCI15_baloni) | C++14 | 255 ms | 27124 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;
const int N = 1000003;
int ara[N],tree[N],n;
vector<int>v;
void update(int indx)
{
while(indx <= n){
tree[indx]++;
indx += indx&-indx;
}
}
int get(int indx)
{
int sum = 0;
while(indx > 0){
sum += tree[indx];
indx -= indx & -indx;
}
return sum;
}
int main()
{
scanf("%d",&n);
for(int i = 1; i <= n;i++)scanf("%d",&ara[i]);
for(int i = n; i >= 1;i--){
update(ara[i]);
v.push_back(get(ara[i]));
}
sort(v.begin(),v.end(),greater<int>());
int cnt = 0,sum = 0;
for(auto i: v){
sum += i;
cnt++;
//cout << i << " ";
if(sum > n)break;
}
cout << cnt << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |