Submission #547089

#TimeUsernameProblemLanguageResultExecution timeMemory
547089HanksburgerExhibition (JOI19_ho_t2)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[100005];
vector<int> vec;
multiset<int> s;
int b[100005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m, index=1;
	cin >> n >> m;
	for (int i=1; i<=n; i++)
		cin >> a[i].first >> a[i].second;
	for (int i=1; i<=m; i++)
		cin >> b[i];
	sort(a+1, a+n+1);
	sort(b+1, b+m+1);
	for (int i=1; i<=m; i++)
	{
		while (index<=n && a[index].first<=b[i])
		{
			s.insert(a[index].second);
			index++;
		}
		if (s.empty())
			continue;
		int x=(*s.begin());
		int pos=upper_bound(vec.begin(), vec.end(), x)-vec.begin();
		if (pos==vec.size())
			vec.push_back(x);
		else
		{
			s.insert(vec[pos]);
			vec[pos]=x;
		}
		s.erase(x);
	}
	cout << vec.size();
	return 0;
}

Compilation message (stderr)

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:31:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   if (pos==vec.size())
      |       ~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...