| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 10686 | gs13068 | 즐거운 채소 기르기 (JOI14_growing) | C++98 | 12 ms | 4604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<cstdio>
#include<algorithm>
std::pair<int,int> a[300001];
int BIT[300001];
void upd(int x){while(x<=300000){BIT[x]++;x+=x&-x;}}
int sum(int x){int r=0;while(x){r+=BIT[x];x-=x&-x;}return r;}
int main()
{
long long r=0;
int i,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&a[i].first);
a[i].second=i;
}
std::sort(a+1,a+n+1);
for(i=1;i<=n;i++)
{
r+=std::min(a[i].second-sum(a[i].second)-1,n-a[i].second-i+sum(a[i].second)+1);
upd(a[i].second);
}
printf("%lld",r);
}
| # | 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... | ||||
