1 条题解
-
0
自动搬运
来自洛谷,原作者为

theb0t
CNOIer搬运于
2025-08-24 21:33:30,当前版本为作者最后更新于2025-01-01 16:42:13,作者可能在搬运后再次修改,您可在原文处查看最新版自动搬运只会搬运当前题目点赞数最高的题解,您可前往洛谷题解查看更多
以下是正文
使用队列存储每一个船上的每一个人,当一条新的船到达时,把之前超时的人弹出队列,然后输出答案。
#include <bits/stdc++.h> #define ll long long using namespace std; struct node { int timee,country; }q[300005]; int cnt[100005],ans; int head,tail; int main() { //freopen("a.txt","r",stdin); int T; cin>>T; while(T--) { int t,k; cin>>t>>k; for(int i=1;i<=k;i++) { int x; cin>>x; q[++tail]={t,x}; cnt[x]++; if(cnt[x]==1) ans++; } while(head<tail&&t-q[head].timee>=86400) { cnt[q[head].country]--; if(cnt[q[head].country]==0) ans--; head++; } cout<<ans<<'\n'; } return 0; }
- 1
信息
- ID
- 1023
- 时间
- 1000ms
- 内存
- 125MiB
- 难度
- 3
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者