Submission
# | When | Author | Problem | Language | CPU | Memory | |
---|---|---|---|---|---|---|---|
20890 | 2024-06-29 10:17:26 | Muntasir_Mahmud | The Picky Penguins' Party | C | 1 ms | 2012 kb | Wrong Answer - 2 |
Source Code
#include <stdio.h> #include <stdbool.h> #include <stdlib.h> void penguin_party(int T, int test_cases[][100000], int sizes[]) { for (int t = 0; t < T; t++) { int N = sizes[t]; int* A = test_cases[t]; long long total_sum = 0; // Calculate the total sum for (int i = 0; i < N; i++) { total_sum += A[i]; } // Check if total sum is odd if (total_sum % 2 != 0) { continue; } long long target_sum = total_sum / 2; dp[0] = true; // Dynamic programming to find if target_sum is achievable for (int i = 0; i < N; i++) { for (long long j = target_sum; j >= A[i]; j--) { if (dp[j - A[i]]) { dp[j] = true; } } } if (dp[target_sum]) { } else { } } } int main() { int T = 2; int test_cases[2][100000] = { {2, 2}, {1, 2, 4, 3} }; int sizes[2] = {2, 4}; penguin_party(T, test_cases, sizes); return 0; }