// la 3135 Argus
// 学习一下优先队列的使用吧,题目还是比较简单的
// 刘老师的训练指南p188。
// 继续练吧。。。。
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define ceil(a,b) (((a)+(b)-1)/(b))
#define endl '\n'
#define gcd __gcd
#define highBit(x) (1ULL<<(63-__builtin_clzll(x)))
#define popCount __builtin_popcountll
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const long double PI = acos(-1.L);
template<class T> inline T lcm(const T& a, const T& b) { return a/gcd(a, b)*b; }
template<class T> inline T lowBit(const T& x) { return x&-x; }
template<class T> inline T maximize(T& a, const T& b) { return a=a<b?b:a; }
template<class T> inline T minimize(T& a, const T& b) { return a=a<b?a:b; }
char s[10];
struct node {
int q;
int peroid;
int time;
node(int q,int peroid,int time):q(q),peroid(peroid),time(time){
}
};
struct cmp{
bool operator ()(node &x,node &y){
if (x.time!=y.time)
return x.time>y.time;
return x.q>y.q;
}
};
int main() {
//freopen("G:\\Code\\1.txt","r",stdin);
priority_queue<node,vector<node>,cmp> que;
while(1){
scanf("%s",s);
if (s[0]=='#')
break;
int x,y;
scanf("%d%d",&x,&y);
que.push(node(x,y,y));
}
int n;
scanf("%d",&n);
while(n--){
node x = que.top();
printf("%d\n",x.q);
que.pop();
que.push(node(x.q,x.peroid,x.time+x.peroid));
}
return 0;
}
la 3135 Argus Data Structure
最新推荐文章于 2016-09-11 15:53:52 发布