답안 #110361

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110361 2019-05-10T18:10:07 Z luciocf Exhibition (JOI19_ho_t2) C++14
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e3+10;

struct P
{
	int s, v;
} p[maxn];

int suf[maxn];

int c[maxn];

int n, m;

bool comp(P a, P b)
{
	if (a.v == b.v) return a.s < b.s;
	return a.v < b.v;
}

int main(void)
{
	scanf("%d %d", &n, &m);

	for (int i = 1; i <= n; i++)
		scanf("%d %d", &p[i].s, &p[i].v);

	for (int i = 1; i <= m; i++)
		scanf("%d", &c[i]);

	sort(p+1, p+n+1, comp);
	sort(c+1, c+m+1);

	suf[n] = p[n].s;
	for (int i = n-1; i >= 1; i--)
		suf[i] = min(suf[i+1], p[i].s);

	int ans = 0, ptr = 1;
	for (int i = 1; i <= m; i++)
	{
		for (; ptr < n && suf[ptr] <= c[i]; ptr++);

		if (ptr <= n)
		{
			ans++;
			ptr++;
		}
	}

	printf("%d\n", ans);
}

Compilation message

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]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &p[i].s, &p[i].v);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &c[i]);
   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -