답안 #83646

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

using namespace std;

#define ll long long
#define pb push_back

struct SegmentTree{
    vector<int> m;
    int n;
    void init(int nn)
    {
        n=nn;
        m.resize(2*n);
    }
    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)
    {
        int 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;
    for(int i=0;i<n;i++)
    {
        scanf("%i %i",&lo,&hi);
        m.set(i,lo);
        if(hi<maxx)
        {
            l++;
            int r=i;
            while(l<r)
            {
                int mid=(l+r)/2;
                int 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;
}

Compilation message

tem.cpp: In function 'int main()':
tem.cpp:49:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&n);
     ~~~~~^~~~~~~~~
tem.cpp:57:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i %i",&lo,&hi);
         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 484 KB Output is correct
2 Correct 2 ms 672 KB Output is correct
3 Correct 2 ms 672 KB Output is correct
4 Correct 2 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 744 KB Output is correct
2 Correct 5 ms 808 KB Output is correct
3 Correct 5 ms 892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 118 ms 7396 KB Output is correct
2 Correct 133 ms 11412 KB Output is correct
3 Correct 139 ms 15900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 245 ms 27544 KB Output is correct
2 Runtime error 272 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.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 322 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 -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 384 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 -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 629 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 -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 202 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 -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 200 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 -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 291 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 -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 274 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 -