Skip to content

Instantly share code, notes, and snippets.

@08shubhamjindal
Last active January 21, 2022 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 08shubhamjindal/8533a9565f1bbc450fe006f4c1a2154a to your computer and use it in GitHub Desktop.
Save 08shubhamjindal/8533a9565f1bbc450fe006f4c1a2154a to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
int main(){
int listofusers[6] = {1,2,3,4,5,6};
int v[7][7] = {0};
int t;
cin>>t;
while(t--){
int paidByUserId,amountPaid,countofIdWhoOws;
cin>>paidByUserId>>amountPaid>>countofIdWhoOws;
int paidforUserIds[countofIdWhoOws];
int amountforUserIds[countofIdWhoOws];
string typeofPayment;
cin>>typeofPayment;
for(int i=0; i<countofIdWhoOws; i++){
cin>>paidforUserIds[i]; // 2,3 // 1,2
}
if(typeofPayment != "Equal"){
for(int i=0; i<countofIdWhoOws; i++){
cin>>amountforUserIds[i]; // 400 //600 // 1500 //500
}
}
if(typeofPayment=="Exact"){
for(int i=0; i<countofIdWhoOws; i++){
v[paidByUserId][paidforUserIds[i]] = v[paidByUserId][paidforUserIds[i]] + amountforUserIds[i];
}
}
else if(typeofPayment == "Percent"){
for(int i=0; i<countofIdWhoOws; i++){
v[paidByUserId][paidforUserIds[i]] = v[paidByUserId][paidforUserIds[i]] + (amountPaid * amountforUserIds[i])/100;
}
}
else{
for(int i=0; i<countofIdWhoOws; i++){
v[paidByUserId][paidforUserIds[i]] = v[paidByUserId][paidforUserIds[i]] + (amountPaid/countofIdWhoOws);
}
}
}
cout<<v[1][2]<<endl;
cout<<v[2][1]<<endl;
int checkUserId;
cin>>checkUserId;
for(int i=0; i<6; i++){
if(checkUserId!=listofusers[i]){
if(v[checkUserId][listofusers[i]]-v[listofusers[i]][checkUserId]<0){
cout<<checkUserId<<" will give to this amount "<<abs(v[checkUserId][listofusers[i]]-v[listofusers[i]][checkUserId])<<"to user"<<listofusers[i]<<endl;
}else if(v[checkUserId][listofusers[i]]-v[listofusers[i]][checkUserId]>0){
cout<<checkUserId<<" owes of this amount "<<v[checkUserId][listofusers[i]]-v[listofusers[i]][checkUserId]<<" from userr"<<listofusers[i]<<endl;
}else{
cout<<"nikal "<<listofusers[i]<<endl;
}
}
}
}
@08shubhamjindal
Copy link
Author

@Ankush22Bairwa look into this

@08shubhamjindal
Copy link
Author

5
1 1200 2 Exact 2 3 200 1000
1 1000 3 Exact 1 2 4 200 200 600
2 2000 2 Exact 1 4 500 1500
4 2000 4 Exact 1 2 5 4 500 200 1000 300
1 1000 5 Exact 1 2 3 4 5 200 200 200 200 200
1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment