Submission #4544875
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using VS = vector<string>; using LL = long long;
using VI = vector<int>; using VVI = vector<VI>;
using PII = pair<int, int>; using PLL = pair<LL, LL>;
using VL = vector<LL>; using VVL = vector<VL>;
#define ALL(a) begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3")
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x)
#endif
const int INF = 1e9; const LL LINF = 1e16;
const LL MOD = 1000000007; const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 }; int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
/* ----- 2019/03/11 Problem: ABC 091 C / Link: http://abc091.contest.atcoder.jp/tasks/abc091_c ----- */
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
LL N; cin >> N;
using tp = tuple<int, int, int>;
vector<tp>events;
FOR(i, 0, N) {
LL x, y; cin >> x >> y;
events.push_back(tp(x, y, 0));
}
FOR(i, 0, N) {
LL x, y; cin >> x >> y;
events.push_back(tp(x, y, 1));
}
SORT(events);
multiset<int>Reds;
LL ans = 0;
for (auto e : events) {
int x, y, id;
tie(x, y, id) = e;
if (id) { // blue
auto it = Reds.lower_bound(y);
if (it != Reds.begin()) {
it--;
ans++;
Reds.erase(it);
}
}
else {
Reds.insert(y);
}
}
cout << (ans) << "\n";
return 0;
}
Submission Info
| Submission Time |
|
| Task |
C - 2D Plane 2N Points |
| User |
Yang33 |
| Language |
C++14 (GCC 5.4.1) |
| Score |
400 |
| Code Size |
1721 Byte |
| Status |
AC |
| Exec Time |
3 ms |
| Memory |
256 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
400 / 400 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
example_0, example_1, example_2, example_3, example_4 |
| All |
example_0, example_1, example_2, example_3, example_4, line_0, line_1, line_2, line_3, maxrand_0, maxrand_1, maxrand_2, maxrand_3, maxrand_4, rand_0, rand_1, rand_2 |
| Case Name |
Status |
Exec Time |
Memory |
| example_0 |
AC |
1 ms |
256 KiB |
| example_1 |
AC |
1 ms |
256 KiB |
| example_2 |
AC |
1 ms |
256 KiB |
| example_3 |
AC |
3 ms |
256 KiB |
| example_4 |
AC |
1 ms |
256 KiB |
| line_0 |
AC |
1 ms |
256 KiB |
| line_1 |
AC |
1 ms |
256 KiB |
| line_2 |
AC |
1 ms |
256 KiB |
| line_3 |
AC |
1 ms |
256 KiB |
| maxrand_0 |
AC |
1 ms |
256 KiB |
| maxrand_1 |
AC |
1 ms |
256 KiB |
| maxrand_2 |
AC |
1 ms |
256 KiB |
| maxrand_3 |
AC |
1 ms |
256 KiB |
| maxrand_4 |
AC |
1 ms |
256 KiB |
| rand_0 |
AC |
1 ms |
256 KiB |
| rand_1 |
AC |
1 ms |
256 KiB |
| rand_2 |
AC |
1 ms |
256 KiB |