-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC_Dungeon.cpp
More file actions
53 lines (48 loc) · 1.24 KB
/
C_Dungeon.cpp
File metadata and controls
53 lines (48 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
int t;cin>>t;
while(t--){
int n,m;cin>>n>>m;
vector<int>a(n),b(m),c(m);
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<m;i++) cin>>b[i];
for(int i=0;i<m;i++) cin>>c[i];
vector<pair<int,int>>vp(m);
multiset<int>ms;
for (int i = 0; i < n; i++)
{
ms.insert(a[i]);
}
for (int i = 0; i < m; i++)
{
vp[i]={b[i],c[i]};
}
sort(vp.begin(),vp.end());
int ans=0;
for (int i = 0; i < m; i++)
{
if(vp[i].second==0) continue;
auto it= ms.lower_bound(vp[i].first);
if(it==ms.end()) break;
int val=*it;
ms.erase(it);
ms.insert(max(val,vp[i].second));
ans++;
}
for (int i = 0; i < m; i++)
{
if(vp[i].second) continue;
auto it= ms.lower_bound(vp[i].first);
if(it==ms.end()) break;
int val=*it;
ms.erase(it);
//ms.insert(max(val,vp[i].second));
ans++;
}
cout<<ans<<endl;
}
return 0;
}