Showing posts with label ACM ICPC Dhaka Regional Preliminary Contest 2015 Solution. Show all posts
Showing posts with label ACM ICPC Dhaka Regional Preliminary Contest 2015 Solution. Show all posts

Monday, 2 November 2015

B. Search the Khoj_Solution

/*
Tanzila Islam
Southeast University
mail : tanzilamohita@gmail.com
Problem Link:
https://algo.codemarshal.org/contests/DRP2015/problems/B
*/

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

bool match (string a, string b) {
    int flag = 0;


    for (int i=0; i<a.length(); i++) {
        if (a[i] != b[i]) {
            flag++;
        if (flag >1) return false;
        }
    }
    return true;

}

int main (void) {
    int t;
    //scanf("%d", &t)
    cin >> t;
    for (int i=1; i<=t; i++) {
        int n;
        scanf("%d", &n);
        //cin >> n;
        string array[n];
        for (int j=0; j<n; j++) {
            cin>>array[j];
        }
        string key;
        cin >> key;

        printf("Case %d:\n", i);

        for (int j=0; j<n; j++) {
            //cout << array[j] << endl;
            bool result = match (key, array[j]);
            if (result) cout << array[j] <<endl;
        }

    }
}

A. Back to the Past_Solution

/*
Tanzila Islam
Southeast University
mail : tanzilamohita@gmail.com
Problem Link:
https://algo.codemarshal.org/contests/DRP2015/problems/A
*/
#include<stdio.h>
int main()
{
     printf("May 29, 2013 Wednesday\n");
     return 0;
}

G. Geek Power Inc._Solution

/*
Tanzila Islam
Southeast University
mail : tanzilamohita@gmail.com
Problem Link:
https://algo.codemarshal.org/contests/DRP2015/problems/G
*/

#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
    pair<int,int>pii[51];
    int n, t;
    long long int tot,ans;
    //long long int tot;
    cin >> t;

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

        cin >> n;
        for(int i=0;i<n;i++)
        cin >> pii[i].second >> pii[i].first;
        sort(pii, pii+n);
        tot = 0;
        for(int i= 0; i < n;i++)
        tot+=pii[i].second;
        ans = tot * pii[0].first;
        for (int i=1; i <n;i++){
            tot-=pii[i-1].second;
            ans = max(ans,tot*pii[i].first);
        }
        //cout << "Case "ans << endl;
        printf("Case %d: %llu\n", z, ans);

    }

        return 0;

}