#include<stdio.h> #include<vector> #include<algorithm> using namespace std; const int MAX_N = 5e5; int n, bit[MAX_N + 1], res; void update(int h, int x) { for (; h; h -= h&-h) bit[h] = max(bit[h], x); } int query(int h) { int x = 0; for (; h <= n; h += h&-h) x = max(x, bit[h]); return x; } int main() { scanf("%d", &n); vector<vector<int>> s(n, { 0,0,0 }); for (int i = 0; i < 3; i++) for (int j = 0, x; j < n; j++) scanf("%d", &x), s[x - 1][i] = n - j; sort(s.begin(), s.end()); for (int i = n - 1; i >= 0; i--) { res += query(s[i][1]) < s[i][2]; update(s[i][1], s[i][2]); } printf("%d", res); return 0; }
2336번: 굉장한 학생
https://www.acmicpc.net/problem/2336
피드 구독하기:
댓글
(
Atom
)
댓글 없음 :
댓글 쓰기