【PAT】1056. Mice and Rice
来源:互联网 发布:手机qq监视器软件 编辑:程序博客网 时间:2024/06/04 18:29
#define LOCAL#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <string>#include <vector>#include <map>#include <set>#include <queue>using namespace std;struct mouse{ int w; int r;}mouse[1010];int main(){ #ifdef LOCAL freopen("data.in","r",stdin); freopen("data.out","w",stdout); #endif // LOCAL int n,m; cin>>n>>m; for(int i=0;i<n;i++){ cin>>mouse[i].w; } int id; queue<int> q; for(int i=0;i<n;i++){ cin>>id; q.push(id); } int t=n,g; while(q.size()!=1){ if(t%m==0)g=t/m; else g=t/m+1; for(int i=0;i<g;i++){ int k=q.front(); for(int j=0;j<m;j++){ if(i*m+j>=t)break; int f=q.front(); if(mouse[k].w<mouse[f].w) k=f; mouse[f].r=g+1; q.pop(); } q.push(k); } t=g; } mouse[q.front()].r=1; for(int i=0;i<n;i++){ cout<<mouse[i].r; if(i!=n-1)cout<<" "; } return 0;}
0 0
- PAT 1056. Mice and Rice
- 【PAT】1056. Mice and Rice
- 1056. Mice and Rice (25)-PAT
- PAT 1056. Mice and Rice (25)
- PAT A 1056. Mice and Rice (25)
- PAT 1056. Mice and Rice (25)
- PAT 1056. Mice and Rice (25)
- 【PAT】1056. Mice and Rice (25)
- PAT(A) - 1056. Mice and Rice (25)
- 【PAT甲级】1056. Mice and Rice (25)
- 1056. Mice and Rice (25)PAT甲级
- PAT甲级1056. Mice and Rice (25)
- PAT-A-1056. Mice and Rice (25)
- PAT 1056. Mice and Rice (25)
- PAT 甲级 1056. Mice and Rice (25)
- PAT 1056. Mice and Rice (25)
- 1056. Mice and Rice (25)PAT
- pat 1056 Mice and Rice
- 开始学习Linux内核了
- 写python使用IDLE如何实现调试功能
- 刷新验证码
- java开发规范(转载)
- 如何写Java文档注释(Java Doc Comments)
- 【PAT】1056. Mice and Rice
- 格式化输入输出处理16进制的问题
- Weekly Conclusion : Linux
- PCA的数学原理(非常值得阅读)!!!!
- Linux Data Structure
- unknown的实现遇到问题了
- java堆栈学习
- 记又一家游戏公司面试
- 详细聊聊Javadoc注释规范