RT 求优化时间复杂度
#include <bits/stdc++.h>
using namespace std;
struct node{
bool v; int tim;
};
inline int read()
{
int x = 0, tmp = 1; char ch = getchar();
while (!isdigit(ch))
{
if (ch == '-') tmp = -1;
ch = getchar();
}
while (isdigit(ch)) {x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar();}
return x * tmp;
}int t, k, x, cnt;
map<int, node> a;
int main()
{
int n = read();
while (n--)
{
t = read(), k = read(); cnt = 0;
for (int i = 1; i <= k; i++) {x = read(); a[x] = {1, t};}
for (auto kv:a)
{
if (kv.second.tim > t - 86400 && kv.second.v) cnt++;
else a[kv.first] = {0, kv.second.tim};
}printf("%d\n", cnt);
}
return 0;
}