la 3135 Argus Data Structure

// 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;
}

时间: 2024-07-30 20:27:42

la 3135 Argus Data Structure的相关文章

LA 3135 Argus (优先队列的简单应用)

A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensordata, Internet traffic, nancial tickers, on-line auctions, and transaction logs such as Web usage logsand telephone call records. Likewise, queries over

LA 3135 Argus (优先队列)

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1136 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> using namespace

LA 3135

Argus Time limit: 3.000 seconds A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor data, Internet traffic, financial tickers, on-line auctions, and transaction logs such as Web usage logs and telephone c

(算法竞赛入门经典 优先队列)LA 3135(前K条指令)

A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor data, Internet traffic, financial tickers, on-line auctions, and transaction logs such as Web usage logs and telephone call records. Likewise, queries o

UVALive - 3135 - Argus (优先队列!!)

UVALive - 3135 Argus Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor data, Internet traffic, financi

【暑假】[实用数据结构]UVAlive 3135 Argus

UVAlive 3135 Argus Argus Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor data, Internet traffic, fin

What is “passive data structure” in Android/Java?

From the Android developer web link: http://developer.android.com/reference/android/content/Intent.html, you can find that it says "It (Intent) is basically a passive data structure holding an abstract description of an action to be performed."

[LeetCode] 211. Add and Search Word - Data structure design Java

题目: Design a data structure that supports the following two operations: void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one le

170. Two Sum III - Data structure design

Design and implement a TwoSum class. It should support the following operations: add and find. add - Add the number to an internal data structure.find - Find if there exists any pair of numbers which sum is equal to the value. For example, add(1); ad