제출 #83648

#제출 시각아이디문제언어결과실행 시간메모리
83648nikolapesic2802무제 (POI11_tem)C++14
40 / 100
700 ms33792 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back int ma; const int N=2*1e6; int m[N]; struct SegmentTree{ int n; void init(int nn) { n=nn; for(int i=0;i<N;i++) m[i]=INT_MIN; } void set(int i,int k) { i+=n; m[i]=k; i>>=1; for(;i;i>>=1) m[i]=max(m[2*i],m[2*i+1]); } int get(int l,int r) { ma=INT_MIN; for(l+=n,r+=n;l<=r;l>>=1,r>>=1) { if(l%2==1) { ma=max(ma,m[l]); l++; } if(r%2==0) { ma=max(ma,m[r]); r--; } } return ma; } }; int main() { SegmentTree m; int n; scanf("%i",&n); m.init(n); int l=0; int maxx=INT_MIN; int res=0; int hi,lo,r,mid,d; for(int i=0;i<n;i++) { scanf("%i %i",&lo,&hi); m.set(i,lo); if(hi<maxx) { l++; r=i; while(l<r) { mid=(l+r)/2; d=m.get(mid,i); //printf("%i-%i [%i][%i]=%i\n",l,r,mid,i,d); if(hi<d) { l=mid+1; } else { r=mid; } } maxx=m.get(l,i); } maxx=max(maxx,lo); res=max(res,i-l+1); //printf("%i-%i %i %i\n",l,i,maxx,res); } printf("%i\n",res); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

tem.cpp: In function 'int main()':
tem.cpp:51:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&n);
     ~~~~~^~~~~~~~~
tem.cpp:59:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i %i",&lo,&hi);
         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...