結果
| 問題 | No.2422 regisys? |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-12 15:28:25 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,392 bytes |
| 記録 | |
| コンパイル時間 | 7,619 ms |
| コンパイル使用メモリ | 533,416 KB |
| 実行使用メモリ | 12,704 KB |
| 最終ジャッジ日時 | 2026-07-02 03:12:08 |
| 合計ジャッジ時間 | 12,423 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 59 WA * 2 |
ソースコード
#ifdef SENJAN
#define _GLIBCXX_DEBUG
#else
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace atcoder;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using bint = boost::multiprecision::cpp_int;
using graph=vector<vector<int>>;
template<class T> using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
constexpr int INF32=INT_MAX/2;
constexpr ll INF64=LLONG_MAX/2;
constexpr ld PI=3.14159265358979323846;
constexpr int dx[]={0,0,-1,1,-1,-1,1,1},dy[]={-1,1,0,0,-1,1,-1,1};
template<class T> inline bool chmax(T &a,T b){return a<b?a=b,true:false;}
template<class T> inline bool chmin(T &a,T b){return a>b?a=b,true:false;}
inline void dispYN(bool a){cout<<(a?"YES":"NO")<<endl;}
inline void dispYn(bool a){cout<<(a?"Yes":"No")<<endl;}
inline void dispyn(bool a){cout<<(a?"yes":"no")<<endl;}
void _main();
int main(){cin.tie(0)->sync_with_stdio(0);cout<<fixed<<setprecision(16);_main();}
void _main(){
int n, m; cin >> n >> m;
vector<bool> used(n);
min_priority_queue<pair<ll,int>> x_c, y_c;
for(int i=0; i<n; i++){
ll a; cin >> a;
x_c.push({a,i});
}
for(int i=0; i<n; i++){
ll b; cin >> b;
y_c.push({b,i});
}
min_priority_queue<ll> x_p, y_p;
for(int i=0; i<m; i++){
int t, c; cin >> t >> c;
if(t==0) x_p.push(c);
if(t==1) y_p.push(c);
}
int ans = n;
while(!x_c.empty() && !y_c.empty()){
auto cmp = [&](){
if(x_c.empty()) return false;
if(y_c.empty()) return true;
if(x_c.top()==y_c.top()){
if(x_p.empty()) return false;
if(y_p.empty()) return true;
return (x_p.top()<y_p.top());
}
return (x_c.top().first<y_c.top().first);
};
if(cmp()){
auto [val,idx] = x_c.top(); x_c.pop();
while(!x_p.empty() && x_p.top()<val){
x_p.pop();
}
if(!used[idx] && !x_p.empty() && val<=x_p.top()){
used[idx] = true;
x_p.pop();
ans--;
}
}else{
auto [val,idx] = y_c.top(); y_c.pop();
while(!y_p.empty() && y_p.top()<val){
y_p.pop();
}
if(!used[idx] && !y_p.empty() && val<=y_p.top()){
used[idx] = true;
y_p.pop();
ans--;
}
}
}
cout << ans << endl;
}