답안 #298875

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
298875 2020-09-14T08:57:36 Z jbroeksteeg Exhibition (JOI19_ho_t2) C++14
0 / 100
1 ms 384 KB
#include <iostream>
#include <climits>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <array>
#include <memory>

#define IN(a,b) (a.find(b) != a.end())
#define p(a,b) make_pair(a,b)
#define readVec(a) for (int __i = 0; __i<(int)a.size();__i++){cin>>a[__i];}

// jimjam

template<typename T>
void pMin(T &a, T b) {if (b<a){a=b;}}
template<typename T>
void pMax(T &a, T b) {if (b>a){a=b;}}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& c);
template<typename A, typename B>
std::ostream& operator<<(std::ostream& os, const std::pair<A,B>& c) {std::cout << "(" << c.first << ", " << c.second << ")";return os;}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& c) {
	if (c.size() == 0) {os << "{}"; return os;}
	os << "{" << c[0];
	for (int i = 1; i < (int)c.size(); i++) {os <<", "<<c[i];}
	os << "}";
	return os;
}

const int inf = 2e9;

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, m; cin >> n >> m;
	vector<pair<int,int>> original(n), after;
	for (int i = 0; i < n; i++) {
		cin >> original[i].first >> original[i].second;
	}
	sort(original.begin(),original.end(), [](pair<int,int> a, pair<int,int> b) {return p(max(a.first,a.second),min(a.first,a.second))<p(max(b.first,b.second),min(b.first,b.second)); });
	
	for(pair<int,int> pi: original) {
		if (after.empty() || pi.first>=after.back().first && pi.second>=after.back().second) {
			after.push_back(pi);
		}
	}

	vector<int> frames(m);
	readVec(frames);
	sort(frames.begin(),frames.end());
	int ans=0, pnt=0;
	for (pair<int,int> pi: after) {
		while (pnt<m && frames[pnt]<pi.first) {
			pnt++;
		}
		if (pnt==m) break;
		pnt++;
		ans++;
	}
	cout << ans << endl;

	return 0;
}


Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:53:53: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   53 |   if (after.empty() || pi.first>=after.back().first && pi.second>=after.back().second) {
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -