Submission #1178613


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) REPF(i,0,n)
#define RREP(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

struct segtree {
    int n;
    vector<int> data;
    segtree(int n_) {
        n=1;
        while(n<n_) n*=2;
        data=vector<int>(n<<1,0);
    }
    void update(int i,int x) {
        i+=n-1;
        chmax(data[i],x);
        while(i>0) {
            i=(i-1)/2;
            data[i]=max(data[i*2+1],data[i*2+2]);
        }
    }
    int getmax(int a,int b) {
        return getmax(a,b,0,0,n);
    }
    int getmax(int a,int b,int k,int l,int r) {
        if(b<=l || r<=a) return 0;
        if(a<=l && r<=b) return data[k];
        int dl=getmax(a,b,k*2+1,l,(l+r)/2);
        int dr=getmax(a,b,k*2+2,(l+r)/2,r);
        return max(dl,dr);
    }
};
signed main() {
    int N;
    cin>>N;
    vector<pii> b(N);
    REP(i,N) {
        cin>>b[i].first>>b[i].second;
        b[i].second*=-1;
    }
    sort(ALL(b));
    FORE(x,b) x.second*=-1;
    segtree rmq(100100);
    rmq.update(b[0].second,1);
    REPF(i,1,N) {
        int max=rmq.getmax(0,b[i].second);
        rmq.update(b[i].second,max+1);
    }
    cout<<rmq.getmax(0,100100)<<endl;
    return 0;
}

Submission Info

Submission Time
Task D - プレゼント
User algon
Language C++14 (GCC 5.4.1)
Score 100
Code Size 2894 Byte
Status AC
Exec Time 45 ms
Memory 3840 KB

Judge Result

Set Name Sample Subtask0 All
Score / Max Score 0 / 0 30 / 30 70 / 70
Status
AC × 4
AC × 19
AC × 34
Set Name Test Cases
Sample sample0.txt, sample1.txt, sample2.txt, sample3.txt
Subtask0 subtask0_0.txt, subtask0_1.txt, subtask0_10.txt, subtask0_11.txt, subtask0_12.txt, subtask0_13.txt, subtask0_14.txt, subtask0_2.txt, subtask0_3.txt, subtask0_4.txt, subtask0_5.txt, subtask0_6.txt, subtask0_7.txt, subtask0_8.txt, subtask0_9.txt, sample0.txt, sample1.txt, sample2.txt, sample3.txt
All sample0.txt, sample1.txt, sample2.txt, sample3.txt, subtask0_0.txt, subtask0_1.txt, subtask0_10.txt, subtask0_11.txt, subtask0_12.txt, subtask0_13.txt, subtask0_14.txt, subtask0_2.txt, subtask0_3.txt, subtask0_4.txt, subtask0_5.txt, subtask0_6.txt, subtask0_7.txt, subtask0_8.txt, subtask0_9.txt, subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt
Case Name Status Exec Time Memory
sample0.txt AC 2 ms 2304 KB
sample1.txt AC 2 ms 2304 KB
sample2.txt AC 2 ms 2304 KB
sample3.txt AC 2 ms 2304 KB
subtask0_0.txt AC 3 ms 2304 KB
subtask0_1.txt AC 3 ms 2304 KB
subtask0_10.txt AC 3 ms 2304 KB
subtask0_11.txt AC 3 ms 2304 KB
subtask0_12.txt AC 3 ms 2304 KB
subtask0_13.txt AC 3 ms 2304 KB
subtask0_14.txt AC 3 ms 2304 KB
subtask0_2.txt AC 2 ms 2304 KB
subtask0_3.txt AC 3 ms 2304 KB
subtask0_4.txt AC 3 ms 2304 KB
subtask0_5.txt AC 2 ms 2304 KB
subtask0_6.txt AC 3 ms 2304 KB
subtask0_7.txt AC 3 ms 2304 KB
subtask0_8.txt AC 3 ms 2304 KB
subtask0_9.txt AC 3 ms 2304 KB
subtask1_0.txt AC 28 ms 3328 KB
subtask1_1.txt AC 3 ms 2304 KB
subtask1_10.txt AC 32 ms 3840 KB
subtask1_11.txt AC 32 ms 3840 KB
subtask1_12.txt AC 45 ms 3840 KB
subtask1_13.txt AC 45 ms 3840 KB
subtask1_14.txt AC 45 ms 3840 KB
subtask1_2.txt AC 9 ms 2560 KB
subtask1_3.txt AC 38 ms 3584 KB
subtask1_4.txt AC 44 ms 3840 KB
subtask1_5.txt AC 8 ms 2560 KB
subtask1_6.txt AC 34 ms 3456 KB
subtask1_7.txt AC 19 ms 2944 KB
subtask1_8.txt AC 39 ms 3712 KB
subtask1_9.txt AC 21 ms 2944 KB