• Argus UVALive


    有一系列的事件,它每Period秒钟就会产生编号为qNum的事件,你的任务是模拟出前k个事件,如果多个事件同时发生,先处理qNum小的事件

    今天再看看数据结构。。

    #include <iostream>
    #include <cstdio>
    #include <sstream>
    #include <cstring>
    #include <map>
    #include <set>
    #include <vector>
    #include <stack>
    #include <queue>
    #include <algorithm>
    #include <cmath>
    #define rap(i, a, n) for(int i=a; i<=n; i++)
    #define MOD 2018
    #define LL long long
    #define ULL unsigned long long
    #define Pair pair<int, int>
    #define mem(a, b) memset(a, b, sizeof(a))
    #define _  ios_base::sync_with_stdio(0),cin.tie(0)
    //freopen("1.txt", "r", stdin);
    using namespace std;
    const int maxn = 10010, INF = 0x7fffffff;
    
    struct node
    {
        int value, time, T;
        bool operator < (const node& a) const {
            return time > a.time || (time == a.time && value > a.value);
        }
    };
    
    int main()
    {
        priority_queue<node> q;
        char s[20];
        while(scanf("%s", s) && s[0] != '#')
        {
            node e;
            scanf("%d%d", &e.value, &e.T);
            e.time = e.T;
            q.push(e);
        }
        int k;
        cin>> k;
        while(k--)
        {
            node e = q.top();
            q.pop();
            cout<< e.value <<endl;
            e.time += e.T;
            q.push(e);
        }
    
        return 0;
    }
    自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。
  • 相关阅读:
    【小技巧】如何输入未知长度的数组,用回车结束输入
    Python基础(二)
    Python基础(一)
    Appium Mac 环境安装
    c# 多线程
    c# 并行计算
    C# 反射
    VI 编辑器
    Linq and Lambda
    WINDOWS 命令
  • 原文地址:https://www.cnblogs.com/WTSRUVF/p/9437030.html
Copyright © 2020-2023  润新知