Submission #99008

# Submission time Handle Problem Language Result Execution time Memory
99008 2019-02-28T05:20:54 Z kriii Exhibition (JOI19_ho_t2) C++17
0 / 100
2 ms 256 KB
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;

int N,M,C;
pair<int, int> pic[100100];
int sz[100100],bit[100100];
map<int, int> chk;

int out(int x)
{
	int r = 0;
	while (x){
		r = max(r,bit[x]);
		x -= x & (-x);
	}
	return r;
}

void in(int x, int p)
{
	while (x <= C){
		bit[x] = max(bit[x],p);
		x += x & (-x);
	}
}

int main()
{
	scanf ("%d %d",&N,&M);
	for (int i=0;i<N;i++){
		scanf ("%d %d",&pic[i].first,&pic[i].second);
		pic[i].first = -pic[i].first;
		chk[pic[i].second] = 0;
	}
	for (auto &p : chk) p.second = ++C;
	for (int i=0;i<N;i++) pic[i].second = chk[pic[i].second];
	sort(pic,pic+N);
	for (int i=0;i<M;i++){
		scanf ("%d",&sz[i]);
		sz[i] = -sz[i];
	}
	sort(sz,sz+M);

	for (int i=0;i<N;i++){
		int u = out(pic[i].second);
		if (sz[u] > pic[i].first){
			u = lower_bound(sz,sz+M,pic[i].first) - sz;
			if (sz[u] <= pic[i].first) u++;
		}
		else u++;
		in(pic[i].second,u);
	}
	printf ("%d\n",out(C));

	return 0;
}

Compilation message

joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d %d",&N,&M);
  ~~~~~~^~~~~~~~~~~~~~~
joi2019_ho_t3.cpp:33:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d %d",&pic[i].first,&pic[i].second);
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t3.cpp:41:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d",&sz[i]);
   ~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -