답안 #951789

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
951789 2024-03-22T16:08:12 Z SmuggingSpun Exhibition (JOI19_ho_t2) C++14
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
#define taskname "exhibition"
using namespace std;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(taskname".inp", "r")){
		freopen(taskname".inp", "r", stdin);
	}
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>>a(n);
	for(auto& [x, y] : a){
		cin >> x >> y;
	}
	sort(a.begin(), a.end(), [&] (auto i, auto j) -> bool{
		return i.second < j.second || (i.second == j.second && i.first < j.first);
	});
	vector<int>c(m);
	for(int& x : c){
		cin >> x;
	}
	sort(c.begin(), c.end(), greater<int>());
	int low = 1, high = m, ans;
	while(low <= high){
		int mid = (low + high) >> 1;
		for(int i = mid - 1, p = 0; i > -1; i--){
			while(p < n && a[p].first > c[i]){
				p++;
			}
			if(p < n){
				p++;
			}
			else{
				high = mid - 1;
				break;
			}
		}	
		if(high != mid - 1){
			low = (ans = mid) + 1;
		}
	}
	cout << ans;
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:12:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   12 |  for(auto& [x, y] : a){
      |            ^
joi2019_ho_t2.cpp:7:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |   freopen(taskname".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:42:10: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   42 |  cout << ans;
      |          ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -