Wednesday, 24 June 2015

Movie Show ( ACM ICPC DHAKA Regional Preliminary 2014)

/*

Tanzila Islam
CSE, Southeast University.
Dhaka-Bangladesh.
id : https://www.facebook.com/prieontypurnotamohita
mail: tanzilamohita@gmail.com
blog: http://tanzilamohita.blogspot.com/

Contest Question Link : https://algo.codemarshal.org/contests/icpc-2014-pre/problems/C

*/

#include<iostream>
#include<cstdio>
using namespace std;

int main (void) {

    //freopen("input.txt", "r", stdin);
    int n;
    scanf("%d", &n);

    for (int i=1; i<=n; i++) {
        int time, t;
        scanf("%d %d", &time, &t);
        //string name, type;
        //int duration;
        string arrayName[t];
        string arrayType[t];
        int arrayDuration[t];

        for (int j=0; j<t; j++) {
            cin >> arrayName[j] >> arrayType[j] >> arrayDuration[j];
        }


        int minDuration = 0;

        for (int a=0; a<t; a++) {

            if (arrayType[a] == "Action") {

                for (int b=0; b<t; b++) {

                    if (arrayType[b] == "Comedy") {

                        for (int c=0; c<t; c++) {
                            if (arrayType[c] == "Horror") {
                                //cout << "working" << endl;
                                    for (int d=0; d<t; d++) {
                                            if (arrayType[d] != "Animation") continue;

                                            int tempDuration = arrayDuration[a] + arrayDuration[b] + arrayDuration[c] + arrayDuration[d];

                                            if (tempDuration>minDuration && tempDuration<= time) {
                                                minDuration = tempDuration;
                                            }

                                    }
                            }
                        }
                    }
                }
            }
        }
        if (minDuration == 0) printf("Case %d: Movie show canceled!\n", i);
        else printf("Case %d: %d\n", i, minDuration);
    }
    return 0;
}

No comments:

Post a Comment