1129. Recommendation System (25)
来源:互联网 发布:张大奕五家淘宝店 编辑:程序博客网 时间:2024/05/17 01:43
1129. Recommendation System (25)
#include <iostream>#include <vector>#include <unordered_map>#include <set>#include <algorithm>using namespace std;struct node{ int idx,w; node(int x,int y):idx(x),w(y){} bool operator <(const node &nd)const { if(w!=nd.w) return w>nd.w; return idx<nd.idx; }};int main(){ int n,k; unordered_map<int,int> cnt; set<node> mset; cin>>n>>k; for(int i=0;i<n;++i) { int idx; cin>>idx; if(i>0) { cout<<idx<<":"; int s=0; for(auto it=mset.begin();it!=mset.end()&&s!=k;++it,++s) cout<<" "<<it->idx; cout<<endl; } auto it=mset.find(node(idx,cnt[idx])); if(it!=mset.end()) mset.erase(it); mset.insert(node(idx,++cnt[idx])); } return 0;}
0 0
- 1129. Recommendation System (25)
- 1129. Recommendation System (25)
- 1129. Recommendation System (25)
- 1129. Recommendation System (25)
- 1129. Recommendation System (25)
- 1129. Recommendation System (25)
- 1129. Recommendation System (25)
- PAT 1129. Recommendation System (25)
- 1129. Recommendation System (25) set
- 1129. Recommendation System (25)[set集合-排序]
- PAT甲级 1129. Recommendation System (25)
- PAT 1129. Recommendation System (25) 数数
- 【PAT】【Advanced Level】1129. Recommendation System (25)
- PAT 甲级 1129. Recommendation System (25)
- 1129. Recommendation System 解析
- PAT--1129. Recommendation System
- PAT(A)-1129. Recommendation System (25)(优先队列)
- pat 1129. Recommendation System (25)(set的增删)
- HDU 5542 (DP+树状数组优化)
- Window Operator如何调用用户自定义的窗口函数Window Function的代码分析
- mysql fashback 5.6 5.7
- CImage在OnPaint()函数中保存图片
- [BZOJ2259]异化多肽(生成函数+NTT+多项式求逆)
- 1129. Recommendation System (25)
- 面向对象的陷阱——instanceof运算符的陷阱
- Android设置无标题或者全屏
- The user specified as a definer ('root'@'%') does not exist
- Shell脚本
- android 自定义相机Camera
- 数据降维方法总结
- AsyncTask的使用&&理解
- MySQL