Showing posts with label Contest Problem Solution. Show all posts
Showing posts with label Contest Problem Solution. Show all posts

Wednesday, 24 June 2015

Keep Rafa at Chelsea ( Dhaka Regional Preliminary 2014 Mock)

/*

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-mock/problems/H

*/


#include<iostream>

#include<cstdio>

using namespace std;


int main (void) {




    int t=0;

    cin >> t;


    for (int i=1; i<=t; i++) {

            int n;

            cin >> n;


            int canStay=0;

            int deathLimit=3;

            int curDeathLimit=0;


            for (int j=1; j<=n; j++) {

                string line;

                cin >> line;


                if (curDeathLimit < deathLimit) {


                        if (line == "W") curDeathLimit = 0;

                        else if (line == "D" || line == "L") curDeathLimit++;


                        canStay++;

                }

            }


            cout << "Case " << i << ": ";

            if (curDeathLimit<deathLimit) cout << "Yay! Mighty Rafa persists!" << endl;

            else cout << canStay << endl;


    }

}

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;
}