标签:
1 5 2 3 Sorey 3 Rose 3 Maltran 3 Lailah 5 Mikleo 6 1 1 4 2 1 2 3
Sorey Lailah Rose
<span style="font-size:18px;">#include <iostream> #include <cstdio> #include <cstring> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <cmath> #include <algorithm> using namespace std; const double eps = 1e-6; const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const int MOD = 1000000007; #define ll long long #define CL(a,b) memset(a,b,sizeof(a)) #define lson (i<<1) #define rson ((i<<1)|1) #define MAXN 150010 struct node { int id,v; char name[220]; bool operator < (const node &tmp) const { if(v == tmp.v) return id < tmp.id; return v > tmp.v; } }p[MAXN]; struct opendoor { int a,b; bool operator < (const opendoor &tmp) const { return a < tmp.a; } }od[MAXN]; set<node> s; int query[110]; int main() { int T,n,m,q; scanf("%d",&T); while(T--) { s.clear(); scanf("%d%d%d",&n,&m,&q); for(int i=1; i<=n; i++) { scanf("%s %d",p[i].name, &p[i].v); p[i].id = i; } for(int i=0; i<m; i++) scanf("%d%d",&od[i].a, &od[i].b); sort(od, od+m); int maxq; for(int i=0; i<q; i++) { scanf("%d",&query[i]); maxq = max(maxq, query[i]); } vector <int> ans; int cnt = 0; for(int i=1; i<=n&&ans.size()<maxq; i++) { s.insert(p[i]); while(od[cnt].a==i && cnt<m) { for(int j=0; j<od[cnt].b&&!s.empty()&&ans.size()<maxq; j++) { ans.push_back(s.begin()->id); s.erase(s.begin()); } cnt++; } } while(!s.empty() && ans.size()<maxq) { ans.push_back(s.begin()->id); s.erase(s.begin()); } for(int i=0; i<q; i++) { if(i) printf(" "); cout<<p[ans[query[i]-1]].name; } puts(""); } return 0; } </span>
HDU5437 Alisha’s Party(优先队列+模拟)
标签:
原文地址:http://blog.csdn.net/d_x_d/article/details/51162108