UVA 119 - Greedy Gift Givers

UVA Sep 1, 2020

Problem PDF

Solution:

/*************************************
******** Team : BUBT_HIDDEN **********
**************************************
*********** Shipu Ahamed *************
*************************************/

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#define sc scanf
#define pf printf
#define ll long long
#define pi 2*acos(0.0)

#define ff first
#define se second
#define inf (1<<30)                                              //infinity value
#define pb push_back
#define mod  1000000007
#define ST(v) sort(v.begin(),v.end())
#define cover(a,d) memset(a,d,sizeof(a))
#define input freopen("in.txt","r",stdin)
#define output freopen("out.txt","w",stdout)
#define maxall(v) *max_element(v.begin(),v.end())
#define minall(v) *min_element(v.begin(),v.end())
#define un(v) ST(v), v.erase(unique(v.begin(),v.end()),v.end())

using namespace std;
int main()
{

    string name;
    int n,f=0;
    while(cin>>n)
    {
        mapmp;
        vectorv;
        for(int i=0;i>name;
            mp[name]=0;
            v.pb(name);
        }
        int amt,man;
        for(int i=0;i>name;
            cin>>amt>>man;
            if(amt==0 && man==0||man==0) continue;

            mp[name]+=(amt%man)-amt;
            amt=amt/man;
            for(int j=0;j>name;
                mp[name]=mp[name]+amt;
            }
        }
        if(f)
        cout<
https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/119/119.cpp

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.