# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
58284 | okaybody10 | 허수아비 (JOI14_scarecrows) | C++98 | 4067 ms | 6968 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;
typedef pair<int,int> pii;
int main()
{
int n; scanf("%d",&n);
pii v[200007];
for(int i=0;i<n;i++) scanf("%d %d",&v[i].first,&v[i].second);
sort(v,v+n);
int ans=0;
for(int i=0;i<n;i++)
{
stack<int> down,up;
int y=v[i].second;
for(int j=i+1;j<n;j++)
{
int y1=v[j].second;
if(y<y1)
{
if(up.size()==0) up.push(y1);
else if(up.top()>y1) up.push(y1);
}
}
ans+=down.size();
ans+=up.size();
}
return !printf("%d",ans);
}
// 1. 좌표압축
// 2. 세그먼트 트리로 그것보다 큰거과 작은거 관리해주기
// 3. salesman과 동일하게 풀면 될듯
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... |