Submission #107013

#TimeUsernameProblemLanguageResultExecution timeMemory
107013ttjaerom곡선 자르기 (KOI17_cut)C++14
0 / 100
3 ms384 KiB
#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)

cut.cpp: In function 'int main()':
cut.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf(" %d",&n);
     ~~~~~^~~~~~~~~~
cut.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %d %d",&a,&b);
         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...