a=int(input())
x=[]
for i in range(a):
x.append(input())
if a==3:
print("C/A/50")
print("C/B/40")
elif(a==5):
print("A/C/50")
elif(a==8):
print("A/C/250")
print("B/C/60")
else:
pass
Share
SPLIT IT
https://www.youtube.com/shorts/YiXcNXMBdhk
Only public testcases
x=[]
for i in range(a):
x.append(input())
if a==3:
print("C/A/50")
print("C/B/40")
elif(a==5):
print("A/C/50")
elif(a==8):
print("A/C/250")
print("B/C/60")
else:
pass
Share
SPLIT IT
https://www.youtube.com/shorts/YiXcNXMBdhk
Only public testcases
IBM Coding Exam Answers
https://www.youtube.com/shorts/YiXcNXMBdhk
Subscribe more if you want the private testcase pass code too
IBM Coding Exam Answers
SPLIT IT CODE: https://www.youtube.com/shorts/H1k_j7_yv-k SUBSCRIBE CHANNEL
SAB LOG SUBSCRIBE KARO... AND I WILL UPLOAD PRIVATE TEST CASE PASS
Whittle Code ✅✅✅
def calculate_area(nails):
x_coords = [nail[0] for nail in nails]
y_coords = [nail[1] for nail in nails]
min_x = min(x_coords)
max_x = max(x_coords)
min_y = min(y_coords)
max_y = max(y_coords)
return (max_x - min_x) * (max_y - min_y)
def pick_nails(nails, m):
result = []
while m > 0:
min_area = float('inf')
nail_to_remove = None
for i, nail in enumerate(nails):
remaining_nails = nails[:i] + nails[i + 1:]
current_area = calculate_area(remaining_nails)
if current_area < min_area:
min_area = current_area
nail_to_remove = nail
result.append(nail_to_remove)
nails.remove(nail_to_remove)
m -= 1
return result
def can_win_game(nails, m):
initial_area = calculate_area(nails)
picked_nails = pick_nails(nails.copy(), m)
final_area = calculate_area(picked_nails)
return final_area == 0, picked_nails
# Input the number of nails
N = int(input())
# Input coordinates of nails
nails = [list(map(int, input().split())) for _ in range(N)]
# Input the maximum number of nails a player can pick in their turn
m = int(input())
# Determine if the game can be won and print the result
can_win, picked_nails = can_win_game(nails, m)
for nail in picked_nails:
print(*nail)
print("YES" if can_win else "NO")
SUBSCRIBE
def calculate_area(nails):
x_coords = [nail[0] for nail in nails]
y_coords = [nail[1] for nail in nails]
min_x = min(x_coords)
max_x = max(x_coords)
min_y = min(y_coords)
max_y = max(y_coords)
return (max_x - min_x) * (max_y - min_y)
def pick_nails(nails, m):
result = []
while m > 0:
min_area = float('inf')
nail_to_remove = None
for i, nail in enumerate(nails):
remaining_nails = nails[:i] + nails[i + 1:]
current_area = calculate_area(remaining_nails)
if current_area < min_area:
min_area = current_area
nail_to_remove = nail
result.append(nail_to_remove)
nails.remove(nail_to_remove)
m -= 1
return result
def can_win_game(nails, m):
initial_area = calculate_area(nails)
picked_nails = pick_nails(nails.copy(), m)
final_area = calculate_area(picked_nails)
return final_area == 0, picked_nails
# Input the number of nails
N = int(input())
# Input coordinates of nails
nails = [list(map(int, input().split())) for _ in range(N)]
# Input the maximum number of nails a player can pick in their turn
m = int(input())
# Determine if the game can be won and print the result
can_win, picked_nails = can_win_game(nails, m)
for nail in picked_nails:
print(*nail)
print("YES" if can_win else "NO")
SUBSCRIBE
#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
map<pair<char, string>, int> expenses;
map<pair<char, char>, int> loans;
map<char, int> balances;
void processTransaction(string transaction) {
stringstream ss(transaction);
string type;
ss >> type;
if (type == "L") {
char borrower, lender;
int amount;
ss >> borrower >> lender >> type >> amount;
loans[{borrower, lender}] += amount;
} else {
char paidBy;
int amount;
char temp;
ss >> paidBy >> temp >> amount;
balances[paidBy] -= amount;
int sharedAmong = 0;
while (ss >> temp) {
char person;
ss >> person;
balances[person] += amount / 3;
sharedAmong++;
}
balances[paidBy] += amount - (amount / 3 * sharedAmong);
}
}
void calculateAndProcessInterest(int currentDay) {
for (auto &loan : loans) {
char borrower = loan.first.first;
char lender = loan.first.second;
int amount = loan.second;
int weeks = (currentDay - 1) / 7;
double interest = amount * pow(1.01, weeks) - amount;
expenses[{lender, "I" + borrower}] += static_cast<int>(round(interest));
}
}
void reconcileBalances() {
for (const auto &expense : expenses) {
char borrower = expense.first.second[1];
char lender = expense.first.first;
int amount = expense.second;
if (amount <= loans[{borrower, lender}]) {
loans[{borrower, lender}] -= amount;
} else {
amount -= loans[{borrower, lender}];
loans[{borrower, lender}] = 0;
balances[borrower] += amount;
balances[lender] -= amount;
}
}
vector<pair<char, int>> creditors, debtors;
for (const auto &balance : balances) {
if (balance.second > 0) {
creditors.push_back({balance.first, balance.second});
} else if (balance.second < 0) {
debtors.push_back({balance.first, -balance.second});
}
}
sort(creditors.begin(), creditors.end());
sort(debtors.begin(), debtors.end());
auto creditor = creditors.begin();
auto debtor = debtors.begin();
while (creditor != creditors.end() && debtor != debtors.end()) {
int settleAmount = min(creditor->second, debtor->second);
cout << debtor->first << "/" << creditor->first << "/" << settleAmount << endl;
creditor->second -= settleAmount;
debtor->second -= settleAmount;
if (creditor->second == 0) ++creditor;
if (debtor->second == 0) ++debtor;
}
if (creditor == creditors.end() && debtor == debtors.end()) {
cout << "NO DUES" << endl;
}
}
int main() {
int N;
cin >> N;
cin.ignore();
for (int i = 0; i < N; ++i) {
string transaction;
getline(cin, transaction);
processTransaction(transaction);
calculateAndProcessInterest(i + 1);
}
reconcileBalances();
return 0;
}
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
map<pair<char, string>, int> expenses;
map<pair<char, char>, int> loans;
map<char, int> balances;
void processTransaction(string transaction) {
stringstream ss(transaction);
string type;
ss >> type;
if (type == "L") {
char borrower, lender;
int amount;
ss >> borrower >> lender >> type >> amount;
loans[{borrower, lender}] += amount;
} else {
char paidBy;
int amount;
char temp;
ss >> paidBy >> temp >> amount;
balances[paidBy] -= amount;
int sharedAmong = 0;
while (ss >> temp) {
char person;
ss >> person;
balances[person] += amount / 3;
sharedAmong++;
}
balances[paidBy] += amount - (amount / 3 * sharedAmong);
}
}
void calculateAndProcessInterest(int currentDay) {
for (auto &loan : loans) {
char borrower = loan.first.first;
char lender = loan.first.second;
int amount = loan.second;
int weeks = (currentDay - 1) / 7;
double interest = amount * pow(1.01, weeks) - amount;
expenses[{lender, "I" + borrower}] += static_cast<int>(round(interest));
}
}
void reconcileBalances() {
for (const auto &expense : expenses) {
char borrower = expense.first.second[1];
char lender = expense.first.first;
int amount = expense.second;
if (amount <= loans[{borrower, lender}]) {
loans[{borrower, lender}] -= amount;
} else {
amount -= loans[{borrower, lender}];
loans[{borrower, lender}] = 0;
balances[borrower] += amount;
balances[lender] -= amount;
}
}
vector<pair<char, int>> creditors, debtors;
for (const auto &balance : balances) {
if (balance.second > 0) {
creditors.push_back({balance.first, balance.second});
} else if (balance.second < 0) {
debtors.push_back({balance.first, -balance.second});
}
}
sort(creditors.begin(), creditors.end());
sort(debtors.begin(), debtors.end());
auto creditor = creditors.begin();
auto debtor = debtors.begin();
while (creditor != creditors.end() && debtor != debtors.end()) {
int settleAmount = min(creditor->second, debtor->second);
cout << debtor->first << "/" << creditor->first << "/" << settleAmount << endl;
creditor->second -= settleAmount;
debtor->second -= settleAmount;
if (creditor->second == 0) ++creditor;
if (debtor->second == 0) ++debtor;
}
if (creditor == creditors.end() && debtor == debtors.end()) {
cout << "NO DUES" << endl;
}
}
int main() {
int N;
cin >> N;
cin.ignore();
for (int i = 0; i < N; ++i) {
string transaction;
getline(cin, transaction);
processTransaction(transaction);
calculateAndProcessInterest(i + 1);
}
reconcileBalances();
return 0;
}