답안 #670300

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
670300 2022-12-08T16:16:54 Z dozer Exhibition (JOI19_ho_t2) C++14
0 / 100
2 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
#define int long long

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

int check(int x)
{
	int i = 0, j = (m - x);
	while (i < n && j < m)
	{
		int a = pic[i], b = fra[j];
		if (s[a] <= c[b]) i++, j++;
		else i++;
	}
	//cout<<endl;
	if (j == m) 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 bound = min(n, m);
	int ans = 0;
	for (int i = LOGN; i >= 0; i--)
	{
		int tmp = ans + (1<<i);
		if (tmp <= bound && 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 'int32_t main()':
joi2019_ho_t2.cpp:3:25: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
      |                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:35:2: note: in expansion of macro 'fileio'
   35 |  fileio();
      |  ^~~~~~
joi2019_ho_t2.cpp:3:59: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
      |                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:35:2: note: in expansion of macro 'fileio'
   35 |  fileio();
      |  ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -