답안 #638228

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638228 2022-09-05T03:01:03 Z ghostwriter Exhibition (JOI19_ho_t2) C++14
100 / 100
124 ms 14580 KB
#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
*/

Compilation message

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])
      |      ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 3 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 3 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2644 KB Output is correct
14 Correct 2 ms 2680 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 3 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 3 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2644 KB Output is correct
14 Correct 2 ms 2680 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2772 KB Output is correct
21 Correct 2 ms 2772 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2772 KB Output is correct
25 Correct 2 ms 2720 KB Output is correct
26 Correct 2 ms 2772 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 2 ms 2644 KB Output is correct
29 Correct 2 ms 2772 KB Output is correct
30 Correct 2 ms 2696 KB Output is correct
31 Correct 2 ms 2772 KB Output is correct
32 Correct 2 ms 2708 KB Output is correct
33 Correct 2 ms 2644 KB Output is correct
34 Correct 2 ms 2644 KB Output is correct
35 Correct 2 ms 2644 KB Output is correct
36 Correct 2 ms 2772 KB Output is correct
37 Correct 3 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 3 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 3 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2644 KB Output is correct
14 Correct 2 ms 2680 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2772 KB Output is correct
21 Correct 2 ms 2772 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2772 KB Output is correct
25 Correct 2 ms 2720 KB Output is correct
26 Correct 2 ms 2772 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 2 ms 2644 KB Output is correct
29 Correct 2 ms 2772 KB Output is correct
30 Correct 2 ms 2696 KB Output is correct
31 Correct 2 ms 2772 KB Output is correct
32 Correct 2 ms 2708 KB Output is correct
33 Correct 2 ms 2644 KB Output is correct
34 Correct 2 ms 2644 KB Output is correct
35 Correct 2 ms 2644 KB Output is correct
36 Correct 2 ms 2772 KB Output is correct
37 Correct 3 ms 2772 KB Output is correct
38 Correct 81 ms 14580 KB Output is correct
39 Correct 73 ms 11864 KB Output is correct
40 Correct 77 ms 11852 KB Output is correct
41 Correct 74 ms 13020 KB Output is correct
42 Correct 59 ms 6676 KB Output is correct
43 Correct 47 ms 6640 KB Output is correct
44 Correct 82 ms 14548 KB Output is correct
45 Correct 83 ms 12808 KB Output is correct
46 Correct 78 ms 11884 KB Output is correct
47 Correct 96 ms 12328 KB Output is correct
48 Correct 77 ms 11564 KB Output is correct
49 Correct 77 ms 10188 KB Output is correct
50 Correct 51 ms 9492 KB Output is correct
51 Correct 48 ms 6636 KB Output is correct
52 Correct 52 ms 6748 KB Output is correct
53 Correct 48 ms 6692 KB Output is correct
54 Correct 69 ms 11868 KB Output is correct
55 Correct 74 ms 12968 KB Output is correct
56 Correct 44 ms 8008 KB Output is correct
57 Correct 17 ms 3940 KB Output is correct
58 Correct 59 ms 10552 KB Output is correct
59 Correct 84 ms 10700 KB Output is correct
60 Correct 22 ms 4036 KB Output is correct
61 Correct 55 ms 7396 KB Output is correct
62 Correct 96 ms 13052 KB Output is correct
63 Correct 104 ms 12940 KB Output is correct
64 Correct 98 ms 13004 KB Output is correct
65 Correct 107 ms 13084 KB Output is correct
66 Correct 102 ms 13060 KB Output is correct
67 Correct 124 ms 12960 KB Output is correct
68 Correct 95 ms 13008 KB Output is correct
69 Correct 110 ms 12720 KB Output is correct
70 Correct 100 ms 13004 KB Output is correct
71 Correct 94 ms 12128 KB Output is correct
72 Correct 101 ms 12492 KB Output is correct
73 Correct 80 ms 11892 KB Output is correct