답안 #670297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
670297 2022-12-08T16:05:18 Z dozer Exhibition (JOI19_ho_t2) C++14
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define endl "\n"
#define sp " "
#define N 100005
#define LOGN 17

int v[N], s[N], c[N];
int n, m;
vector<int> pic, fra;

int check(int x)
{
	int ans = 0, i = 0, j = (m - x);
	while (i < pic.size() && j < fra.size())
	{
		int a = pic[i], b = fra[j];
		if (s[a] <= c[b]) i++, j++, ans++;
		else i++;
	}
	if (ans == x) return 1;
	return 0;
}

int32_t main()
{
	//fileio();
	fastio();

	cin>>n>>m;
	for (int i = 1; i <= n; i++)
		cin>>s[i]>>v[i];
	for (int i = 1; i <= m; i++)
		cin>>c[i];

	for (int i = 1; i <= n; i++) pic.pb(i);
	for (int j = 1; j <= m; j++) fra.pb(j);

	sort(pic.begin(), pic.end(), [&](int a, int b){
		return v[a] < v[b];
	});

	sort(fra.begin(), fra.end(), [&](int a, int b){
		return c[a] < c[b];
	});

	int ans = 0;
	for (int i = LOGN; i >= 0; i--)
	{
		int tmp = ans + (1<<i);
		if (tmp <= m && check(tmp)) ans = tmp;
	}
	cout<<ans<<endl;

	cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}

Compilation message

joi2019_ho_t2.cpp: In function 'int check(int)':
joi2019_ho_t2.cpp:21:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  while (i < pic.size() && j < fra.size())
      |         ~~^~~~~~~~~~~~
joi2019_ho_t2.cpp:21:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  while (i < pic.size() && j < fra.size())
      |                           ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -