結果

問題 No.2796 Small Matryoshka
ユーザー 矢澤式WINTER矢澤式WINTER
提出日時 2024-06-28 22:02:58
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,595 bytes
コンパイル時間 3,092 ms
コンパイル使用メモリ 255,804 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-06-28 22:03:05
合計ジャッジ時間 4,414 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 12 ms
6,944 KB
testcase_06 AC 69 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 53 ms
6,940 KB
testcase_09 AC 74 ms
7,040 KB
testcase_10 AC 73 ms
7,040 KB
testcase_11 AC 73 ms
7,168 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
/*/
#include <atcoder/all>
using namespace atcoder;
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//*/
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dbgv(x); for(auto now : x) cout << now << " "; cout << endl;
//using P = pair<int,int>;
using ll = long long;
using ull = unsigned long long;
//*/
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vint;
random_device rnd;
mt19937 rng(rnd());

const int INF = 1e9+100;
void solve(){
  int n; cin >> n;
  vector<pair<int,int>> ps(n),dp(n+1,make_pair(INF,INF));
  vint dp2(n+1,0);
  rep(i,n) cin >> ps[i].first >> ps[i].second;
  sort(ALL(ps));
  rep(i,n) swap(ps[i].first,ps[i].second);
  dp[0] = ps[0];
  dp2[0]++;
  rep(i,n)if(i){
    auto it = lower_bound(ALL(dp),make_pair(ps[i].second,ps[i].first));
    int idx = it-dp.begin();
    dp2[idx]++;
    if(*it == make_pair(INF,INF) || it->second > ps[i].first){
      *it = ps[i];
    }
  }
  cout << *max_element(ALL(dp2))-1 << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1; //cin >> t;
  rep(testcase,t) solve();
}
0