結果
問題 |
No.1557 Binary Variable
|
ユーザー |
|
提出日時 | 2025-05-07 17:14:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 1,956 bytes |
コンパイル時間 | 3,585 ms |
コンパイル使用メモリ | 221,168 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-05-07 17:14:22 |
合計ジャッジ時間 | 8,855 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include"bits/stdc++.h" using namespace std; #ifdef ONLINE_JUDGE #define debug(...) 42 #else #include "puppet.h" #endif #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef long double ld; typedef long long ll; typedef unsigned long long ull; #define pb push_back #define pob pop_back #define bplc __builtin_popcountll #define bpc __builtin_popcount #pragma GCC optimize("Ofast") #define F first #define S second #define all(v) v.begin(),v.end() #define unique(v) (v).erase(unique((v).begin(), (v).end()), (v).end()) template<class T> using pbds= tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>; template<class T> using min_heap=priority_queue<T, vector<T>, greater<T>>; // *a.find_by_order(x)-->gives xth element considering 0 indexing // a.order_of_key(x)-->gives number of elements strictly smaller than x // struct custom_hash { // static uint64_t splitmix64(uint64_t x) { // // http://xorshift.di.unimi.it/splitmix64.c // x += 0x9e3779b97f4a7c15; // x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; // x = (x ^ (x >> 27)) * 0x94d049bb133111eb; // return x ^ (x >> 31); // } // size_t operator()(uint64_t x) const { // static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); // return splitmix64(x + FIXED_RANDOM); // } // }; // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void solve(){ int n,m; cin>>n>>m; vector<pair<int,int>>v(m); for(int i=0;i<m;i++)cin>>v[i].F>>v[i].S; sort(all(v)); int l=-2e9,r=2e9; int ans=1; // debug(v); for(auto p:v){ int L=p.F,R=p.S; l=max(l,L); r=min(r,R); debug(L,R); if(l>r){ ans++; l=p.F;r=p.S; } } cout<<n-ans<<"\n"; } int main(){ ios::sync_with_stdio(0); cin.tie(0); int T=1; //cin>>T; while(T--){ solve(); } return 0; }