Submission #128531

# Submission time Handle Problem Language Result Execution time Memory
128531 2019-07-11T05:58:21 Z qkxwsm Exhibition (JOI19_ho_t2) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 100013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N, M;
pii arr[MAXN];
int lim[MAXN];
vi dp;

bool check(int x)
{
	//you need smth 0...x - 1
	vi nums;
	FOR(i, 0, x)
	{
		nums.PB(lim[M - 1 - i]);
	}
	reverse(ALL(nums));
	// for (int y : nums)
	// {
	// 	cerr << y << ' ';
	// }
	// cerr << endl;
	dp.clear();
	dp.PB(0);
	FOR(i, 0, N)
	{
		// cerr << arr[i].se << ',';
		int ind = UB(ALL(dp), arr[i].se) - dp.begin();
		if (ind > x || arr[i].se > nums[ind - 1]) continue;
		if (ind == dp.size()) dp.PB(0);
		dp[ind] = arr[i].se;
	}
	// cerr << endl;
	return (SZ(dp) > x);
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M;
	FOR(i, 0, N)
	{
		cin >> arr[i].se >> arr[i].fi;
	}
	sort(arr, arr + N);
	FOR(i, 0, M)
	{
		cin >> lim[i];
	}
	sort(lim, lim + M);
	int lo = 0, hi = min(N, M);
	while(hi > lo)
	{
		int mid = (hi + lo + 1) >> 1;
		if (check(mid)) lo = mid;
		else hi = mid - 1;
	}
	cout << lo << '\n';
}

Compilation message

joi2019_ho_t2.cpp: In function 'bool check(int)':
joi2019_ho_t2.cpp:65:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (ind == dp.size()) dp.PB(0);
       ~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -