結果
| 問題 | 
                            No.2796 Small Matryoshka
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-06-29 00:54:38 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,336 bytes | 
| コンパイル時間 | 1,700 ms | 
| コンパイル使用メモリ | 172,708 KB | 
| 実行使用メモリ | 16,000 KB | 
| 最終ジャッジ日時 | 2024-06-29 00:54:43 | 
| 合計ジャッジ時間 | 4,261 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 5 WA * 14 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
// OM NAMAH SHIVAY
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long
const int inf = 1e18;
// int dx[4]={-1,0,1,0};
// int dy[4]={0,1,0,-1};
// int dx[8]={0,-1,-1,-1,0,1,1,1};
// int dy[8]={1,1,0,-1,-1,-1,0,1};
const int N = 200200;
const int mod = 1e9+7;
using ii = pair<int,int>;
//write on copy
void solver(){
    int n;
    cin>>n;
    multiset<ii>s;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        s.insert({a,b});
    }
    int ans = 0;
    while(s.size()>1)
    {
        auto it = s.begin();
        int y = it->second;
        s.erase(s.begin());
        ans++;
        
        while(1)
        {
            auto it = s.lower_bound({y,0});
            if(it==s.end()) break;
            int y = it->second;
            s.erase(it);
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    IOS
    //int _t;cin>>_t;while(_t--)
    solver();
    return 0;
}
#undef int