Skip to content

Instantly share code, notes, and snippets.

@saharshg29
Created October 12, 2022 18:14
Show Gist options
  • Save saharshg29/2d0ec0b8582afd6538f9b9533103263b to your computer and use it in GitHub Desktop.
Save saharshg29/2d0ec0b8582afd6538f9b9533103263b to your computer and use it in GitHub Desktop.
#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