Submission #638220

# Submission time Handle Problem Language Result Execution time Memory
638220 2022-09-05T01:23:45 Z ghostwriter Exhibition (JOI19_ho_t2) C++14
0 / 100
0 ms 340 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 N = 1e5 + 1;
int n, m, c[N], d[N], Max = 0, cur = 0, rs = 0;
Pic p[N];
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]) continue;
   		int pos = lb(c + 1, c + 1 + m, p[i].s) - c;
   		d[i] = Max + 1;
   		int cn = max(cur + 1, pos);
   		if (cn < m) {
   			++Max;
   			cur = cn;
   		}
   	}
   	FOR(i, 1, n) rs = max(rs, d[i]);
   	cout << rs;
    return 0;
}
/*
3 3
1 1
1 1
1 1
2
2
2
*/

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:53:5: note: in expansion of macro 'FOR'
   53 |     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:54:5: note: in expansion of macro 'FOR'
   54 |     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:57:5: note: in expansion of macro 'FOR'
   57 |     FOR(i, 1, n) {
      |     ^~~
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:67:5: note: in expansion of macro 'FOR'
   67 |     FOR(i, 1, n) rs = max(rs, d[i]);
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -