제출 #638228

#제출 시각아이디문제언어결과실행 시간메모리
638228ghostwriterExhibition (JOI19_ho_t2)C++14
100 / 100
124 ms14580 KiB
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#endif
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
    Tran The Bao
    CTL - Da Lat
    Cay ngay cay dem nhung deo duoc cong nhan
*/
struct Pic {
	int s, v;
	Pic() {}
	Pic(int s, int v) : s(s), v(v) {}
};
bool cmp(Pic a, Pic b) {
	if (a.v != b.v) return a.v < b.v;
	return a.s < b.s;
}
const int oo = 1e9 + 5;
const int N = 1e5 + 1;
int n, m, c[N], rs = 0;
vi d[N];
Pic p[N];
multiset<int> s;
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // freopen(file".inp", "r", stdin);
    // freopen(file".out", "w", stdout);
   	cin >> n >> m;
   	FOR(i, 1, n) cin >> p[i].s >> p[i].v;
   	FOR(i, 1, m) cin >> c[i];
   	sort(p + 1, p + 1 + n, cmp);
   	sort(c + 1, c + 1 + m);
   	FOR(i, 1, n)
   		if (p[i].s <= c[m]) {
   			s.insert(i);
   			d[lb(c + 1, c + 1 + m, p[i].s) - c].pb(i);
   		}
   	int pre = n + 1;
   	FOS(i, m, 1) {
   		if (s.empty()) {
   			cout << m - i;
   			return 0;
   		}
   		int pos = *--s.end();
   		s.erase(--s.end());
   		FOS(j, pre - 1, pos)
   			if (!s.empty() && *--s.end() >= j && *s.lb(j) == j)
   				s.erase(j);
   		EACH(j, d[i])
   			if (!s.empty() && *--s.end() >= j && *s.lb(j) == j)
   				s.erase(j);
   		pre = pos;
   	}
   	cout << m;
    return 0;
}
/*
4 3
4 2
1 1
5 1
5 5
2
3
5
*/

컴파일 시 표준 에러 (stderr) 메시지

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
joi2019_ho_t2.cpp:56:5: note: in expansion of macro 'FOR'
   56 |     FOR(i, 1, n) cin >> p[i].s >> p[i].v;
      |     ^~~
joi2019_ho_t2.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
joi2019_ho_t2.cpp:57:5: note: in expansion of macro 'FOR'
   57 |     FOR(i, 1, m) cin >> c[i];
      |     ^~~
joi2019_ho_t2.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
joi2019_ho_t2.cpp:60:5: note: in expansion of macro 'FOR'
   60 |     FOR(i, 1, n)
      |     ^~~
joi2019_ho_t2.cpp:25:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   25 | #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
      |                               ^
joi2019_ho_t2.cpp:66:5: note: in expansion of macro 'FOS'
   66 |     FOS(i, m, 1) {
      |     ^~~
joi2019_ho_t2.cpp:25:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   25 | #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
      |                               ^
joi2019_ho_t2.cpp:73:6: note: in expansion of macro 'FOS'
   73 |      FOS(j, pre - 1, pos)
      |      ^~~
joi2019_ho_t2.cpp:26:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   26 | #define EACH(i, x) for (auto &(i) : (x))
      |                               ^
joi2019_ho_t2.cpp:76:6: note: in expansion of macro 'EACH'
   76 |      EACH(j, d[i])
      |      ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...