Saturday, 10 October 2015

UVA 1203 Argus (UVALive 3135, POJ 2051, ZOJ 2212, FZU 1182, Regionals 2004 >> Asia - Beijing)

///     Raihan Ruhin
///     CSE, Jahangirnagar University.
///     Dhaka-Bangladesh.
///     id: raihanruhin (topcoder / codeforces / codechef / uva / uvalive / spoj), 3235 (lightoj)
///     mail: raihanruhin@ (yahoo / gmail / facebook)
///     blog: ruhinraihan.blogspot.com

#include<bits/stdc++.h>
using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define PI acos(-1.0)

#define MOD 1000000007
#define MX 100010

struct Z{
    int id, val, inc;
    bool operator < (Z const p) const{
        if(val==p.val) return id>p.id;
        return val>p.val;
    }
};
Z z;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int tc, kk=1, n, k;
    string s;
    char ch;
    priority_queue<Z>pq;
    while(cin>>s && s!="#")
    {
        cin>>z.id>>z.inc;
        z.val=z.inc;
        pq.push(z);
    }
    cin>>k;
    while(k--)
    {
        z = pq.top();
        pq.pop();
        cout<<z.id<<"\n";
        z.val+=z.inc;
        pq.push(z);
    }
return 0;
}

No comments:

Post a Comment