結果
| 問題 |
No.2422 regisys?
|
| コンテスト | |
| ユーザー |
Rho
|
| 提出日時 | 2023-08-12 15:13:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,036 bytes |
| コンパイル時間 | 4,656 ms |
| コンパイル使用メモリ | 244,552 KB |
| 実行使用メモリ | 45,944 KB |
| 最終ジャッジ日時 | 2024-11-20 00:23:52 |
| 合計ジャッジ時間 | 24,140 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 WA * 53 |
ソースコード
#include <bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using namespace atcoder;
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P>PP;
typedef vector<ll> vi;
constexpr ll inf=1ll<<61;
constexpr ll mod=998244353;
typedef modint998244353 mi;
int a[200005],b[200005],t[200005],c[200005];
int main(){
int n,m;cin>>n>>m;
vector<int>event;
rep(i,n)cin>>a[i];
rep(i,n)cin>>b[i];
rep(i,n){
event.push_back(a[i]);
event.push_back(b[i]);
}
rep(i,m){
cin>>t[i]>>c[i];
event.push_back(c[i]);
}
map<int,int>M;
sort(all(event));
event.erase(unique(all(event)),event.end());
rep(i,event.size()){
M[event[i]]=i;
}
vector<P>V;
rep(i,n){
a[i]=M[a[i]];
b[i]=M[b[i]];
V.push_back(P(b[i],a[i]));
}
vector<int>t0;
rep(i,m){
c[i]=M[c[i]];
if(t[i]==0)t0.push_back(c[i]);
else {
V.push_back(P(c[i],inf));
}
}
sort(all(V));
fenwick_tree<int>fw(event.size());
for(auto e:V){
if(e.second==inf){
if(fw.sum(0,e.first+1)==0)continue;
else{
int ss=fw.sum(0,e.first+1);
int lb=-1,ub=e.first;
while(ub-lb>1){
int mi=(ub+lb)/2;
if(fw.sum(0,mi+1)==ss){
ub=mi;
}
else lb=mi;
}
fw.add(ub,-1);
}
}
else{
fw.add(e.second,1);
}
}
vector<int>V2;
rep(i,event.size()){
while(fw.sum(i,i+1)){
V2.push_back(i);
fw.add(i,-1);
}
}
sort(all(t0));
int ans=V2.size();
int L=0;
rep(i,V2.size()){
while(L<t0.size()){
if(V2[i]>t0[L])L++;
else{
ans--;break;
}
}
}
cout<<ans<<endl;
}
Rho