-
Notifications
You must be signed in to change notification settings - Fork 1
/
1203 - Argus.cpp
93 lines (75 loc) · 1.67 KB
/
1203 - Argus.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*input
*/
#include <stdio.h>
#include <cmath>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string.h>
#include <stack>
#include <map>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;
#define r(input) freopen("input.txt","r",stdin)
#define w(output) freopen("output.txt","w",stdout)
#define FOR(i, a) for ( int i = 0 ; i < a ; i++ )
#define FOREACH(l) for (auto it = l.begin(); it != l.end(); it++)
#define BitCount(i) __builtin_popcount(i)
#define Sort(v) sort(v.begin(),v.end())
#define cover(a, d) memset(a,d,sizeof(a))
#define remove(v,e) v.erase(std::find(v.begin(),v.end(),e))
#define sz size
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define VISITED 1
#define UNVISITED 0
#define INF 1000000000
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef pair<int,ii> triple;
inline int toint(string s){ll v; istringstream sin(s);sin>>v;return v;}
inline ll toll(string s){ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
class Compare
{
public:
bool operator() (ii t1 , ii t2){
return t1>t2;
}
};
int main()
{
priority_queue<ii, vector<ii>, Compare> pq;
map<int , int> m;
m.clear();
while(!pq.empty()) pq.pop();
string s;
int x , y;
while(cin >> s)
{
if ( s == "#") break;
cin >> x >> y;
ii p = mp(y , x);
m[x] = y;
pq.push(p);
}
int n;
cin >> n;
while(n--)
{
ii p = pq.top(); pq.pop();
cout << p.sd << endl;
p.ft = p.ft + m[p.sd];
pq.push(p);
}
}