很奇特的一道模拟
有点不好想啊。。
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
int n, m, t;
const int N = 1e5 + 10;
//订单的顺序
PII order[N];
//score 代表 每个商家的优先值
int score[N];
//表示是否进入
bool st[N];
//表示这个商家 上一次接到订单的时刻
int last[N];
int main()
{
cin >> n >> m >> t;
for (int i = 0; i < m; i++) {
cin >> order[i].first >> order[i].second;
}
sort(order, order + m);
for (int i = 0; i < m; i++) {
int j = i;
while (j < m && order[j] == order[i]) {
j++;
}
int num = order[i].second;
int tim = order[i].first;
int cnt = j-i;
i = j - 1;
score[num] = score[num] - (tim - last[num] - 1);
if (score[num] < 0)score[num] = 0;
if (score[num] <= 3)st[num] = false;
score[num] += cnt * 2;
if (score[num] > 5)
st[num] = true;
last[num] = tim;
}
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++;
}
cout << res << endl;
return 0;
}