Submission #507599

# Submission time Handle Problem Language Result Execution time Memory
507599 2022-01-12T19:38:41 Z Evirir Exhibition (JOI19_ho_t2) C++17
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#define watch(x) cout << (#x) << "=" << (x) << '\n'
#define mset(d, val) memset(d, val, sizeof(d))
#define cbug   \
	if (DEBUG) \
	cout
#define setp(x) cout << fixed << setprecision(x)
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define forn(i, a, b) for (int i = (a); i < (b); i++)
#define fore(i, a, b) for (int i = (a); i <= (b); i++)
#define pb push_back
#define F first
#define S second
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
// template<typename T>
// using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void SD(int t = 0) { cout << "PASSED " << t << endl; }
ostream &operator<<(ostream &out, ii x)
{
	out << "(" << x.F << "," << x.S << ")";
	return out;
}
const ll INF = ll(1e18);
const int MOD = 998244353;

const bool DEBUG = 0;
const int MAXN = 100005;
const int LG = 21;

int n, m;
ii pic[MAXN];
ll f[MAXN];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> n >> m;
	forn(i, 0, n) cin >> pic[i].F >> pic[i].S;
	forn(i, 0, m) cin >> f[i];

	sort(pic, pic+n);
	sort(f, f+m);

	multiset<ll> s;
	forn(i,0,n) s.insert(pic[i].S);
	int p=n-1;
	int ans=0;
	ll last=INF;

	for(int i=m-1;i>=0;i--)
	{
		while(p>=0 && pic[p].F>f[i])
		{
			auto ptr = s.find(pic[p].S);
			if(ptr!=s.end()) s.erase(ptr);
			p--;
		}
		if(s.empty()) break;
		ans++;
		last=*s.rbegin();
		s.erase(--s.end());
	}

	cout<<ans<<'\n';

	return 0;
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:63:5: warning: variable 'last' set but not used [-Wunused-but-set-variable]
   63 |  ll last=INF;
      |     ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -