Submission #100826

# Submission time Handle Problem Language Result Execution time Memory
100826 2019-03-14T19:30:37 Z ikura355 Exhibition (JOI19_ho_t2) C++14
0 / 100
2 ms 384 KB
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define X first
#define Y second
const int maxn = 1e5 + 5;
const int inf = 1e9;

int n,m;
pii a[maxn];
int b[maxn];
int wow[maxn], p[maxn];

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].X,&a[i].Y);
	for(int i=1;i<=m;i++) scanf("%d",&b[i]);
	sort(&a[1],&a[n+1]);
	sort(&b[1],&b[m+1],[&](int x, int y){return x>y;});
	for(int i=n,j=0;i>=1;i--) {
		while(j+1<=m && b[j+1]>=a[i].X) j++;
		wow[i] = j;
	}
	int mx = 0;
	p[0] = inf;
	for(int i=n;i>=1;i--) {
		int l = 0, r = mx, pos = 0;
		while(l<=r) {
			int mid = (l+r)/2;
			if(p[mid]>=a[i].Y) {
				pos = mid+1;
				l = mid+1;
			}
			else r = mid-1;
		}
		if(pos<=wow[i]) {
			p[pos] = a[i].Y;
			mx = max(mx, pos);
		}
	}
	printf("%d",mx);
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
joi2019_ho_t2.cpp:19:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d%d",&a[i].X,&a[i].Y);
                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:20:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=m;i++) scanf("%d",&b[i]);
                        ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -