Submission
# | When | Author | Problem | Language | CPU | Memory | |
---|---|---|---|---|---|---|---|
20824 | 2024-06-09 08:51:31 | AHAMMED_99 | Pocket Money | C | 40 ms | 2356 kb | Accepted |
Source Code
#include <stdio.h> #include <stdlib.h> #define MAX 100000 // Comparator function for qsort int compare(const void *a, const void *b) { return (*(int*)a - *(int*)b); } // Function to find the smallest note greater than or equal to x using binary search int findSmallestNote(int *notes, int size, int x) { int left = 0, right = size - 1; int result = -1; while (left <= right) { int mid = left + (right - left) / 2; if (notes[mid] >= x) { result = notes[mid]; right = mid - 1; } else { left = mid + 1; } } return result; } int main() { int T; while (T--) { int N, D; int notes[MAX]; for (int i = 0; i < N; i++) { } // Sort the notes array int requests[MAX]; for (int i = 0; i < D; i++) { } // Process each request for (int i = 0; i < D; i++) { int request = requests[i]; int result = findSmallestNote(notes, N, request); } } return 0; }