UVALive 3135 Argus

来源:互联网 发布:类图用什么软件画 编辑:程序博客网 时间:2024/06/08 09:00

给出若干个信息,每个都有独立的编号,以及时间间隔。把他们放入优先队列中,每次取时间最小的(多个就取编号小的),输出编号,再把他的时间加上他的时间间隔,再放入优先队列中,执行n次。

注意优先队列的优先级表示法。

#include<algorithm>#include<iostream>#include<cstring>#include<cstdio>#include<vector>#include<string>#include<queue>#include<cmath>///LOOP#define REP(i, n) for(int i = 0; i < n; i++)#define FF(i, a, b) for(int i = a; i < b; i++)#define FFF(i, a, b) for(int i = a; i <= b; i++)#define FD(i, a, b) for(int i = a - 1; i >= b; i--)#define FDD(i, a, b) for(int i = a; i >= b; i--)///INPUT#define RI(n) scanf("%d", &n)#define RII(n, m) scanf("%d%d", &n, &m)#define RIII(n, m, k) scanf("%d%d%d", &n, &m, &k)#define RIV(n, m, k, p) scanf("%d%d%d%d", &n, &m, &k, &p)#define RV(n, m, k, p, q) scanf("%d%d%d%d%d", &n, &m, &k, &p, &q)#define RFI(n) scanf("%lf", &n)#define RFII(n, m) scanf("%lf%lf", &n, &m)#define RFIII(n, m, k) scanf("%lf%lf%lf", &n, &m, &k)#define RFIV(n, m, k, p) scanf("%lf%lf%lf%lf", &n, &m, &k, &p)#define RS(s) scanf("%s", s)///OUTPUT#define PN printf("\n")#define PI(n) printf("%d\n", n)#define PIS(n) printf("%d ", n)#define PS(s) printf("%s\n", s)#define PSS(s) printf("%s ", n)///OTHER#define pb(x) push_back(x)#define CLR(a, b) memset(a, b, sizeof(a))#define CPY(a, b) memcpy(a, b, sizeof(b))#define display(A, n, m) {REP(i, n){REP(j, m)PIS(A[i][j]);PN;}}using namespace std;typedef long long LL;typedef pair<int, int> P;const int MOD = 100000000;const int INFI = 1e9 * 2;const LL LINFI = 1e17;const double eps = 1e-6;const double pi = acos(-1.0);const int N = 11;const int M = 11;const int move[8][2] = {0, 1, 0, -1, 1, 0, -1, 0, 1, 1, 1, -1, -1, 1, -1, -1};struct node{    int num, p, t;    node(){};    node(int a, int b, int c){num = a, p = b, t = c;};    bool operator < (const node a) const    {        return (a.t == t) ? a.num < num : a.t < t;    }}m;priority_queue<node> q;char s[N];int main(){    //freopen("input.txt", "r", stdin);    //freopen("output.txt", "w", stdout);    int a, b, n;    while(!q.empty())q.pop();    while(cin >> s && s[0] == 'R')    {        cin >> a >> b;        q.push(node(a, b, b));    }    cin >> n;    while(n--)    {        m = q.top();        q.pop();        cout << m.num << endl;        q.push(node(m.num, m.p, m.p + m.t));    }    return 0;}