Example #1
0
int main()
{
    Reader rr;
    int t = rr.next_u32();

    while (t--) {
        rr.skip_line();
        rr.next_real_line(str, len);
        for (int i = 0; i < len; ++i)
            str[i] = toupper(str[i]);

        title = string(str);
        m = rr.next_u32();
        n = rr.next_u32();
        b = rr.next_u32();

        HM hm;

        while (m--) {
            rr.next(str);
            int c = rr.next_u32();
            Datum d(str, c);
            hm.add(d);
        }

        RV recipes;
        while (n--) {
            rr.skip_line();
            rr.next_real_line(str, len);
            string recipe = string(str);

            int n_ing = rr.next_u32();
            int recipe_cost = 0;

            while (n_ing--) {
                rr.next(str);
                int k = rr.next_u32();

                recipe_cost += hm.get(string(str)) * k;
            }
            if (recipe_cost <= b)
                recipes.push_back(Recipe(recipe, recipe_cost));
        }

        printf("%s\n", title.c_str());
        if (recipes.size() > 0) {
            sort(recipes.begin(), recipes.end());
            cFor (RV, r, recipes)
                printf("%s\n", (r->name).c_str());
        }
        else
            puts("Too expensive!");
        putchar('\n');
    }

    return 0;
}
Example #2
0
int main(void){

	HM *h = HM_HM();
	printf("Adding: %s\n","one");	
	h->put(h,"one",3,1);
	printf("Size: %d\n",h->size);
	printf("Adding: %s\n","two");
	h->put(h,"two",3,2);
	printf("Size: %d\n",h->size);
	
	printf("Get: %s Result: %d \n","two",h->get(h,"two",3));
	printf("Get: %s Result: %d \n","one",h->get(h,"one",3));
	
	printf("Exists: %s  %s\n","two",h->exists(h,"two",3)?"YES":"NO");
	printf("Exists: %s  %s\n","zero",h->exists(h,"zero",4)?"YES":"NO");
	
	
	
	return 0;
}
Example #3
0
int main()
{
    Reader rr;
    while (rr.has_next()) {
        n = rr.next_u32();
        m = rr.next_u32();

        HM hm;

        for (int i = 1; i <= n; ++i) {
            int v = rr.next_u32();
            hm.add(v, i);
        }
        while (m--) {
            int k = rr.next_u32();
            int v = rr.next_u32();
            printf("%d\n", hm.get(v, k));
        }
    }

    return 0;
}