Submission #753423

#TimeUsernameProblemLanguageResultExecution timeMemory
753423IvanJExhibition (JOI19_ho_t2)C++17
100 / 100
77 ms5580 KiB
#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define all(a) (a).begin(), (a).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 1e5 + 5;

int n, m;
int s[maxn], v[maxn], c[maxn];
vector<ii> V;

int check(int pos) {
	for(ii p : V) 
		if(pos < m && p.y <= c[pos]) pos++;
	return (pos == m);
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i = 0;i < n;i++) 
		scanf("%d%d", s + i, v + i);
	for(int i = 0;i < m;i++) 
		scanf("%d", c + i);
	
	for(int i = 0;i < n;i++) V.pb({v[i], s[i]});
	sort(all(V));
	sort(c, c + m);
	
	int lo = 0, hi = m - 1, ans = m;
	while(lo <= hi) {
		int mid = (lo + hi) / 2;
		if(check(mid)) ans = mid, hi = mid - 1;
		else lo = mid + 1;	
	}
	
	printf("%d\n", m - ans);
	return 0;
}

Compilation message (stderr)

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |   scanf("%d%d", s + i, v + i);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   scanf("%d", c + i);
      |   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...