PII orders[N]; int score[N]; bool st[N]; bool f[N];
intmain() { scanf("%d%d%d", &n, &m, &T); for (int i = 0; i < m; i++) scanf("%d%d", &orders[i].x, &orders[i].y); for (int i = 1; i <= T; i++) { for (int j = 0; j < m; j++) { int id = orders[j].y, t = orders[j].x; if (t == i) { f[id] = true; score[id] += 2; if (score[id] > 5) st[id] = true; } } for (int j = 1; j <= n; j++) if (!f[j]) { score[j]--; score[j] = max(score[j], 0); if (score[j] <= 3) st[j] = false; } memset(f, false, sizeof(f)); } int res = 0; for (int i = 1; i <= n; i++) if (st[i]) res++; printf("%d", res); return0; }
int n, m, T; int score[N], last[N]; bool st[N]; PII orders[N];
intmain() { scanf("%d%d%d", &n, &m, &T); for (int i = 0; i < m; i++) scanf("%d%d", &orders[i].x, &orders[i].y); sort(orders, orders + m); for (int i = 0; i < m; ) { int j = i; while (j < m && orders[j] == orders[i]) j++; int id = orders[i].y, t = orders[i].x, cnt = j - i; i = j; score[id] -= t - last[id] - 1; score[id] = max(0, score[id]); if (score[id] <= 3) st[id] = false; score[id] += 2 * cnt; if (score[id] > 5) st[id] = true; last[id] = t; } for (int i = 1; i <= n; i++) { if (last[i] < T) { score[i] -= T - last[i]; if (score[i] <= 3) st[i] = false; } } int res = 0; for (int i = 1; i <= n; i++) if (st[i]) res++; printf("%d", res); return0; }