样例
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define x first
#define y second
using namespace std;
typedef pair<int,int> PII;
const int N = 100010;
int score[N],last[N];
bool st[N];
int n,m,T;
int res;
PII order[N];
int main()
{
cin >> n >> m >> T;
for(int i = 0; i < m; i++) scanf("%d",&order[i].x,&order[i].y);
sort(order,order + m);
for(int i = 0; i < m;)
{
int j = i;
while(j < m && order[j] == order[i]) j++;
int t = order[i].x,id = order[i].y,cnt = j - i;
i = j;
score[id] -= t - last[id] - 1;
if(score[id] < 0) score[id] = 0;
if(score[id] <= 3) st[id] = false;
score[id] += cnt * 2;
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;
}
}
for(int i = 1; i <= n; i++)
{
res += st[i];
}
cout << res << endl;
return 0;
}
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla