This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Solve Sum in Python | |
| def solve_sum(A, B): | |
| """ | |
| This function implements a greedy approach to minimize the sum difference | |
| among two sets A and B | |
| """ | |
| C = sorted(A + B, reverse=True) # Join both subsets and sort them in reversed order | |
| a_sum = 0 | |
| b_sum = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Main in python | |
| def main(): | |
| T = int(input()) | |
| for t in range(T): | |
| N = int(input()) # Read N | |
| if N==-1: | |
| break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Main in Kotlin | |
| fun main() { | |
| val T:Int = readln().toInt(); // Read number of cases | |
| for (t in 0..T-1) { | |
| var N:Int = readln().toInt(); // Read N int | |
| if (N == -1) { | |
| break |
OlderNewer