You are viewing a single comment's thread. Return to all comments →
int* serviceLane(int n, int cases_rows, int cases_cols, int* width, int cases[][2], int* result_count) { int* result = (int*)malloc(cases_rows * sizeof(int)); for (int i = 0; i < cases_rows; i++) { int min_width = width[cases[i][0]]; for (int j = cases[i][0]; j <= cases[i][1]; j++) { if (width[j] < min_width) { min_width = width[j]; } } result[i] = min_width; } *result_count = cases_rows; return result; } int main() { int n, t; scanf("%d %d", &n, &t); int width[n]; for (int i = 0; i < n; i++) { scanf("%d", &width[i]); } int cases[t][2]; for (int i = 0; i < t; i++) { scanf("%d %d", &cases[i][0], &cases[i][1]); } int result_count; int* result = serviceLane(n, t, 2, width, cases, &result_count); for (int i = 0; i < result_count; i++) { printf("%d\n", result[i]); } free(result); #Pratham Gupta return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Service Lane
You are viewing a single comment's thread. Return to all comments →