STL-queue解ALDS1_1_3_B:Queue
来源:互联网 发布:如何关闭淘宝手机店铺 编辑:程序博客网 时间:2024/05/20 10:22
代码:
#include <cstdio>#include <iostream>#include <queue>#include <algorithm>#include <cstring>using namespace std;int main(){string name;int n,q,t;queue<pair<string, int> > Q; //>与>之间有空格 cin>>n>>q;for(int i=0;i<n;i++) {cin>>name>>t;Q.push(make_pair(name, t));}pair<string, int> u;int elaps = 0,a; //elaps消逝的时间while(!Q.empty()) {u = Q.front(); Q.pop();a = min(u.second, q); //执行时间片q或时间u.t的处理 u.second -= a; //计算剩余所需时间 elaps += a; //累计已经过的时间if(u.second > 0) {Q.push(u);} else {cout<<u.first<<" "<<elaps<<endl;}}return 0; } /*pair是保存成对结构体的模板,声明时需要在<>中指令两个数据类型。make_pair 用于生成一堆数值,第一个元素通过first访问,第二个通过second访问。 */
阅读全文
0 0
- STL-queue解ALDS1_1_3_B:Queue
- STL--Queue
- STL QUEUE
- stl-queue
- stl queue
- stl queue
- stl queue
- STL queue
- STL queue
- STL-queue
- STL--queue
- STL queue
- STL queue
- stl-queue
- STL queue
- STL QUEUE
- stl priority queue
- stl queue使用...
- 96. Unique Binary Search Trees(通过观察递推式意思找递推关系)
- web.xml較好的頭文件
- JZOJsenior3455.【NOIP2013模拟联考3】库特的向量(code)
- Java 入门知识
- powerdesigner显示列描述信息
- STL-queue解ALDS1_1_3_B:Queue
- [NOIP2016真题]蚯蚓
- HDU(1004)Let the Balloon Rise
- CNN--based Network Architectures
- 迷宫算法的细化(C++)
- memcache 雪崩现象
- HDU 6158 计算几何 笛卡尔定理 + 韦达定理
- 国赛----可见光室内定位
- 使用Windows API实现SOCKET Ping 范例源代码