답안 #83656

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
83656 2018-11-09T15:17:45 Z nikolapesic2802 Temperature (POI11_tem) C++14
50 / 100
1000 ms 33792 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
int ma;
const int N=2*1e6+5;
int m[N];
int n;
int i,k,l0,l,r,r0,nn;
int maxx=INT_MIN;
int res=0;
int hi,lo,mid,d,a;
struct SegmentTree{
    void set()
    {
        a+=n;
        m[a]=k;
        a>>=1;
        for(;a;a>>=1)
            m[a]=max(m[2*a],m[2*a+1]);
    }
    int get()
    {
        ma=INT_MIN;
        for(l0+=n,r0+=n;l0<=r0;l0>>=1,r0>>=1)
        {
            if(l0%2==1)
            {
                ma=max(ma,m[l0]);
                l0++;
            }
            if(r0%2==0)
            {
                ma=max(ma,m[r0]);
                r0--;
            }
        }
        return ma;
    }
};


int main()
{
    SegmentTree m;
    //n=1e6;
    //scanf("%i",&n);
    cin >> n;
    assert(n<N);
    for(i=0;i<n;i++)
    {
        //scanf("%i %i",&lo,&hi);
        cin >> lo >> hi;
        a=i;
        k=lo;
        m.set();
        if(hi<maxx)
        {
            l++;
            r=i;
            while(l<r)
            {
                mid=(l+r)/2;
                l0=mid;
                r0=i;
                d=m.get();
                //printf("%i-%i   [%i][%i]=%i\n",l,r,mid,i,d);
                if(hi<d)
                {
                    l=mid+1;
                }
                else
                {
                    r=mid;
                }
            }
            l0=l;
            r0=i;
            maxx=m.get();
        }
        maxx=max(maxx,lo);
        res=max(res,i-l+1);
    }
    printf("%i\n",res);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 612 KB Output is correct
2 Correct 9 ms 676 KB Output is correct
3 Correct 11 ms 676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 245 ms 4264 KB Output is correct
2 Correct 280 ms 4728 KB Output is correct
3 Correct 345 ms 5328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 619 ms 6392 KB Output is correct
2 Correct 651 ms 6796 KB Output is correct
3 Execution timed out 1018 ms 6932 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 820 ms 6932 KB Output is correct
2 Correct 708 ms 7004 KB Output is correct
3 Execution timed out 1087 ms 7004 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1040 ms 7512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1077 ms 7512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 412 ms 7512 KB Output is correct
2 Correct 438 ms 12652 KB Output is correct
3 Correct 431 ms 17996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 422 ms 17996 KB Output is correct
2 Correct 445 ms 23808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 782 ms 23808 KB Output is correct
2 Execution timed out 1088 ms 33792 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Runtime error 777 ms 33792 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -