HUST 1341 a-a Simple Task (Harbin Tech Asia Qualifying practice)

Source: Internet
Author: User

A-A Simple TaskTime Limit:MS Memory Limit:131072KB 64bit IO Format:%lld &A mp %llu SubmitStatusPracticeHUST 1341

Description

As is known to all, lots of birds be living in HUST. A Bird hassUnits of the first day, and eatskUnits of food each day. So they must find food in school or they would die. Because food was not this easy-to-find, birds store it home on the tree. If One bird runs out of the food some day, he just dies. (It means that if the bird doesn ' t has enough food stored and can ' t find enough food that day, he'll die.) A Professor is researching on the birds. He has got some records of the birds ' everyday life. And you, as his student, is to tell him the birds ' state after the last day on the records of the bird.

Input

The first line was an integer, representing the number of test cases. The first line contains one integerNRepresenting the number of records. The next line contains-integers-sandk, representing the unit of food on the first day and the number of unit a bird needs. The nextNLines, each contains a piece of record. The first word of each record is the name of a bird. You can assume this every bird has a distinct name and the name have no white space. The name has only alphabetical letters, i.e. A-Z and a-Z. The following-integers is the date and the unit of food, the bird found on the. (1<=N<=100000, the other integers is all greater than or equal to 1 and less than or equal to 10000.) Hint:the date of records May is disordered, but a bird ' s name would only appear once on each day. And the bird ' s name may appear even if he died before, so can assume its the "error in the records and just ignore it.

Output

Output "Case #T: "Before each test case on a". For each test case, print out the name of the "All" and the birds and his food store, each bird a line. The output should is in Alphabet order. If A bird died some day, you just tell the Professor the bird is dead. The format is as the sample output. And you should the check sample output for details. Output a blank line after each case.

Sample Input

33100 3Gaewah 4 3Gaewah 5Gaewah 1 10Smith 3410 5peterpan 7 3Oxford 3 5Scheme 2 100Regexp 1 10

Sample Output

Case #1: Gaewah died. Case #2: Smith died. Case #3: Oxford 0Regexp 15Scheme 100peterpan died.the details of this topic are particularly disgusting people hanging 2 rounds. 
/*=============================================================================## Author:liangshu-cbam # # QQ        : 756029571 # # School: Harbin Polytechnic University # # last modified:2015-08-30 21:48## filename:a.cpp## Description: # The people who is crazy enough to think they can change the world, is the ones who does! =============================================================================*/# #include <iostream># include<sstream> #include <algorithm> #include <cstdio> #include <string.h> #include < cctype> #include <string> #include <cmath> #include <vector> #include <stack> #include <    queue> #include <map> #include <set>using namespace std;const int INF = 100003;struct a{string str; int d, F;}    E[inf];bool CMP (a A, a B) {if (a.str = = b.str) return A.D < B.D; return A.str < B.str;}    int main () {int t;    cin>>t;    int cs = 1;    while (t--) {map<string,int>cnt;    Map<string,int >dict;        int n, s, K;        int dd,ff;        String str;        scanf ("%d", &n);        scanf ("%d%d", &s, &k);            for (int i = 0; i < n; i++) {cin>>str>>dd>>ff;            E[i].str = str;            E[I].D = DD;            E[I].F = FF;            CNT[STR] = s;            dict[str]++;        cout<< "E =" <<E[0].str<<endl;        } sort (E, E + N, CMP);        int i;            for (i = 0; i < n; i++) {Cnt[e[i].str]-= (e[i].d-1) * k;                if (Cnt[e[i].str] >= 0) {Cnt[e[i].str] + = E[I].F;                CNT[E[I].STR]-= k;                    for (int j = 1; j < Dict[e[i].str]; J + +) {int m = (e[i + j].d-e[i + j-1].d-1);                    CNT[E[I].STR]-= m* k;      if (cnt[e[i].str]>= 0) {Cnt[e[i].str] + = E[i + j].f;                  CNT[E[I].STR]-= k;//cout<< "x =" <<cnt[E[i].str]<<endl;        }}} i + = Dict[e[i].str];        I-= 1;        } printf ("Case #%d:\n", cs++);            for (int i = 0; i < n; i++) {//cout<< "E[I].STR =" <<E[i].str<<endl; if (Cnt[e[i].str] < 0) {cout<<e[i].str<< "" << "died."                <<endl;            CNT[E[I].STR] = 1000000004; } else if (cnt[e[i].str]! = 1000000004) {cout<<e[i].str<< "" <<cnt[                e[i].str]<<endl;            CNT[E[I].STR] = 1000000004;    }} cout<<endl; } return 0;} /*234810 5A 3 5B 2 20B 5 5B 6 0B 7 5C 1 5C 3 5C 4 10*/


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HUST 1341 a-a Simple Task (Harbin Tech Asia Qualifying practice)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.