Created
October 12, 2022 18:14
-
-
Save saharshg29/2d0ec0b8582afd6538f9b9533103263b to your computer and use it in GitHub Desktop.
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
#include <stdio.h> | |
int main(void) | |
{ | |
// your code goes here | |
int n, x, y; | |
int sum = 0; | |
int day = 0; | |
int k = 1; | |
scanf("%i", &n); | |
scanf("%i", &x); | |
scanf("%i", &y); | |
int arr1[n], arr2[n]; | |
for (int i = 0; i < n; i++) | |
{ | |
scanf("%i", &arr1[i]); | |
} | |
for (int i = 0; i < n; i++) | |
{ | |
scanf("%i", &arr2[i]); | |
} | |
while (k > 0) | |
{ | |
for (int i = 0; i < n; i++) | |
{ | |
arr1[i] += arr2[i]; | |
} | |
day++; | |
for (int i = 0; i < n; i++) | |
{ | |
if (arr1[i] >= y) | |
{ | |
sum += arr1[i]; | |
arr1[i] = 0; | |
if (sum > x) | |
{ | |
printf("%i", day); | |
k = -1; | |
break; | |
} | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment