#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
struct pic{
ll v,s;
bool operator <(const pic& rhs) const{
return v < rhs.v;
}
};
vector <pic> arr;
vector <ll> frame;
ll ans = 0;
ll n,m;
void func(ll i,vector<ll>s){
if (i == n){
ll j = 0;
bool ok = false;
for (ll z=0;z<s.size() && j < m;z++,j++){
while (j < m && s[z] > frame[j]){
j++;
}
if (j < m) ans = max(ans,z+1);
}
return;
}
func(i+1,s);
s.push_back(arr[i].s);
func(i+1,s);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
arr.resize(n);
for (int z=0;z<n;z++){
cin >> arr[z].s >> arr[z].v;
}
frame.resize(m);
for (int z=0;z<m;z++){
cin >> frame[z];
}
sort(arr.begin(),arr.end());
sort(frame.begin(),frame.end());
vector <ll> temp;
func(0,temp);
cout << ans << endl;
}
Compilation message
joi2019_ho_t2.cpp: In function 'void func(ll, std::vector<long long int>)':
joi2019_ho_t2.cpp:34:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (ll z=0;z<s.size() && j < m;z++,j++){
~^~~~~~~~~
joi2019_ho_t2.cpp:33:14: warning: unused variable 'ok' [-Wunused-variable]
bool ok = false;
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |