bzoj1206: [HNOI2005]虚拟内存
来源:互联网 发布:数码大师类似软件 编辑:程序博客网 时间:2024/05/16 18:08
题意
这么长的题面肯定要自己看啊
题解
我投机取巧,用了我蹩脚的STL瞎写了一波
#include<cstdio>#include<iostream>#include<algorithm>#include<set>#include<map>using namespace std;int n,m;set<pair<int,pair<int,int> > > S;//出现的次数 出现的时间 值是什么set<pair<int,pair<int,int> > >::iterator it;map<int,int> p,p1;//时间 位置 int ans=0;int main(){ int shen=0;//现在里面有多少个数 scanf("%d%d",&n,&m); for (int u=1;u<=m;u++) { int x; scanf("%d",&x); if (p[x]==0)//这个值一开始不存在 { p[x]=u;p1[x]=1; if (shen<n)//不够n个数 { S.insert(make_pair(p1[x],make_pair(p[x],x))); shen++; } else { it=S.lower_bound(make_pair(0,make_pair(0,0))); p[it->second.second]=0;p1[it->second.second]=0; S.erase(it); S.insert(make_pair(p1[x],make_pair(p[x],x))); } } else { ans++; it=S.find(make_pair(p1[x],make_pair(p[x],x))); p1[x]++; S.insert(make_pair(p1[x],make_pair(p[x],x))); S.erase(it); } } printf("%d\n",ans); return 0;}
阅读全文
0 0
- bzoj1206: [HNOI2005]虚拟内存
- 【BZOJ1206】【HNOI2005】虚拟内存,我也就能写写这种模拟题了
- [HNOI2005]虚拟内存
- BZOJ 1206: [HNOI2005]虚拟内存
- bzoj 1206: [HNOI2005]虚拟内存
- bzoj 1206: [HNOI2005]虚拟内存
- BZOJ 1206 [HNOI2005] 虚拟内存 题解
- BZOJ 1206 [HNOI2005] 虚拟内存 题解与分析
- BZOJ 1206 [HNOI2005] 虚拟内存 题解与分析
- [BZOJ]1206: [HNOI2005]虚拟内存 线段树
- 虚拟内存
- 虚拟内存
- 虚拟内存
- 虚拟内存
- 虚拟内存
- 虚拟内存
- 虚拟内存
- 虚拟内存
- poj 1182 食物链(经典种类并查集)
- windows7旗舰版,vs2015下配置opencv3.3.0
- 自学总结2
- linux 5
- 【Unity】Unity Mac版本破解
- bzoj1206: [HNOI2005]虚拟内存
- CAP理论十二年回顾:"规则"变了
- QT
- java中的BigDecimal和String的相互转换
- 训练集样本不平衡问题对CNN的影响
- coreldraw做倒影总会让人发现有意想不到的效果呈现出来
- AngularJS 防止页面闪烁的方法
- 第六章图像滤波低通滤波器
- 单源最短路径问题