পৃষ্ঠাসমূহ

সোমবার, ৮ ফেব্রুয়ারি, ২০১৬

URI Online Judge | 1318 Fake Tickets Solution

URI Online Judge | 1318 Fake Tickets
Language:C++
Solution:



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

int main()
{


    int N,M,num,fakeCount;

    while(cin>>N>>M)
    {
        fakeCount = 0;
        map<int,int> tickets;
        fakeCount = 0;
        if(N==0&&M==0)
            break;


        for(int i = 0; i<M; i++)
        {
          cin>>num;
            tickets[num]++;
          }

    map<int,int>::iterator i;
    for( i = tickets.begin();i!=tickets.end();i++){
          if(i->second>1)
          fakeCount++;


    }
    cout<<fakeCount<<endl;


    }



}

URI Online Judge | 1281 Going to the Market Solution



#include <iostream>
#include <map>
#include <iomanip>

using namespace std;

int main()
{

    int n,m,p,prodCount;
    string prod;
    double price,totalPrice;
    map<string,double> products;
    cin>>n;
    while(n-->0)
    {
        totalPrice = 0;
        cin>>m;
        for(int i = 0; i<m; i++)
        {
            cin>>prod>>price;
            products[prod] = price;



        }
        cin>>p;
        for(int i = 0; i<p; i++)
        {
            cin>>prod>>prodCount;
            totalPrice += products[prod]*prodCount;


        }
        cout<<fixed<<setprecision(2)<<"R$ "<<totalPrice<<endl;

        products.clear();
    }

}


URI Online Judge | 1533 Detective Watson Solution



#include <iostream>
#include <climits>
#include <vector>
#include <algorithm>
using namespace std;

struct number
{
    int pos;
    int num;
};
bool compare(number a,number b)
{
    return a.num>b.num;
}

int main()
{

    int n;
    vector<number> suspectLevel;
    while(cin>>n&&n)
    {

        number N;
        for(int i = 0; i<n; i++)
        {
            cin>>N.num;
            N.pos = i;

            suspectLevel.push_back(N);
        }

        sort(suspectLevel.begin(),suspectLevel.end(),compare);
        N = suspectLevel.at(1);
        cout<<N.pos+1<<endl;
        suspectLevel.clear();

    }

}