답안 #679551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
679551 2023-01-08T13:31:40 Z ethening Exhibition (JOI19_ho_t2) C++17
0 / 100
1 ms 320 KB
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

struct pic {
	int sz, val;
};

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<pic> p;
	vector<int> f;
	for (int i = 0; i < n; i++) {
		int sz, val;
		cin >> sz >> val;
		p.push_back({.sz = sz, .val = val});
	}
	for (int i = 0; i < m; i++) {
		int c;
		cin >> c;
		f.push_back(c);
	}
	sort(p.begin(), p.end(), [](pic &u, pic &v) {
		if (u.val < v.val) return true;
		else if (u.val > v.val) return false;
		else return u.sz < v.sz;
	});
	sort(f.begin(), f.end());
	multiset<pair<int, int>> MS;
	for (int i = 0; i < m; i++) {
		MS.insert(make_pair(f[i], i));
	}

	vector<int> minOkF(n);
	for (int i = 0; i < n; i++) {
		// cout << p[i].sz << " $$\n";
		minOkF[i] = -1;
		auto iter = MS.lower_bound(make_pair(p[i].sz, -1));
		if (iter == MS.end()) continue;
		minOkF[i] = iter -> second;
		MS.erase(iter);
	}

	// for (int i = 0; i < n; i++) {
	// 	cout << minOkF[i] << " ";
	// }

	int ans = 0;
	int pnt = m - 1;
	for (int i = n - 1; i >= 0; i--) {
		if (minOkF[i] == -1) continue;
		if (minOkF[i] <= pnt) {
			++ans;
			--pnt;
		}
	}

	cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -