# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
107013 | ttjaerom | 곡선 자르기 (KOI17_cut) | C++14 | 3 ms | 384 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<stdio.h>
#include<queue>
#include<algorithm>
#include<stack>
using namespace std;
int n;
int m;
priority_queue<pair<int,int> > q;
stack<int> s;
int temp;
int t=1;
int t2=0;
int ans1=1;
int ans2;
int buho(int a)
{
if(a<0) return 1; //음수면 리턴1
return 0; //양수면 리턴0
}
int main()
{
scanf(" %d",&n);
int i;
int a,b;
for(i=1;i<=n;i++)
{
scanf(" %d %d",&a,&b);
if(i==1)
{
if(buho(b)==1) temp=-1;
else temp=1;
}
if(buho(temp)!=buho(b)) //전좌표 현좌표 y좌표 부호가 다르면
{
q.push(make_pair(a,t));
t2++;
if(t2%2==0) t++;
}
temp=b;
}
s.push(q.top().second);
q.pop();
for(i=2;i<=t;i++)
{
m=q.top().second;
if(s.top()==q.top().second)
{
s.pop();
q.pop();
}
else
{
if(s.empty()) ans1++;
s.push(q.top().second);
q.pop();
}
if(q.top().second==m) ans2++;
}
printf("%d %d",ans1,ans2);
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... |