20pts求调
查看原帖
20pts求调
947029
Chen_Three楼主2024/5/20 20:01
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
int n, m, t, cnt = 0;
int dingdan[N];
bool is_first[N] ;
struct node {
	int ts, id;
} a[N];
bool cmp(node nodea, node nodeb) {
	if (nodea.id == nodeb.id) {
		return nodea.ts < nodeb.ts;
	}
	return nodea.id < nodeb.id;
}
void chuli(int nn) {
	int z = 0, sum, tempts;
	for (int i = 1; i <= m; i++) {
		if (a[i].id != nn) {
			break;
		}
		z++;
		dingdan[z] = a[i].ts;
	}
	tempts = a[1].ts;
	sum = 3;
	for (int i = 2; i <= z; i++) {
		tempts = a[i].ts;
		sum = max(sum + 3 - (a[i].ts - a[i - 1].ts), 0);
		if (is_first[nn]) {
			if (sum <= 3) {
				is_first[nn] = 0;
			}
		} else {
			if (sum > 5) {
				is_first[nn] = 1;
			}
		}
	}
	tempts = t;
	sum = max(sum - (t - a[z].ts), 0);
	if (is_first[nn]) {
		if (sum <= 3) {
			is_first[nn] = 0;
		}
	} else {
		if (sum > 5) {
			is_first[nn] = 1;
		}
	}
}
int main() {
	cin >> n >> m >> t;
	for (int i = 1; i <= m; i++) {
		cin >> a[i].ts >> a[i].id;
	}
	sort(a + 1, a + m + 1, cmp);
//	for (int i = 1; i <= m; i++) {
//		cout << a[i].ts << ' ' << a[i].id << endl;
//	}
	for (int i = 1; i <= n; i++) {
		chuli(i);
	}
	for (int i = 1; i <= n; i++) {
		if (is_first[i]) {
			cnt++;
		}
	}
	cout << cnt;
	return 0;
}
2024/5/20 20:01
加载中...