Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef struct lol {
- int x, y, z;
- } troll;
- int a[3505], i, j, rs, t, n, arb[3505][3505];
- troll c[3505];
- bool cmp(const troll & a, const troll & b) {
- return a.z < b.z;
- }
- int query(int x, int y) {
- int rs = 0;
- for (int i = x; i >= 1; i -= -i & i)
- for (int j = y; j >= 1; j -= -j & j)
- rs = max(rs, arb[i][j]);
- return rs;
- }
- void update(int x, int y, int z) {
- for (int i = x; i <= n; i += -i & i)
- for (int j = y; j <= n; j += -j & j)
- if (z > arb[i][j]) arb[i][j] = z;
- }
- int main() {
- cin >> n;
- for(t = 1; t > 0; --t) {
- for (i = 1; i <= n; ++i)
- cin >> c[i].x >> c[i].y >> c[i].z;
- sort(c + 1, c + n + 1, cmp);
- for (rs = 1, i = 1; i <= n; ++i)
- a[i] = query(c[i].x, c[i].y) + 1,
- update(c[i].x, c[i].y, a[i]), rs = max(rs, a[i]);
- cout << rs << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement