Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/ #include <stdio.h> int main() { int n, p, q, tst, i, j; scanf("%d", &tst); for(i=1; i<=tst; i++) { scanf("%d%d%d", &n, &p, &q); int ara[n], cnt=0, sum=0; for(j=0; j<n ;j++) { scanf("%d", &ara[j]); sum += ara[j]; if(cnt<p && sum<=q) cnt++; } printf("Case %d: %d\n", i, cnt); } return 0; }
#include
ReplyDeleteusing namespace std;
int main()
{
int t , j , count;
while(1==scanf("%d",&t))
{
j=0;
while(t--)
{
int n , p , q ;
cin>>n>>p>>q;
int i = 0 , arr[n];
for(i=0;i>arr[i];
}
std::sort(arr,arr+n);
if(n=0 && arr[i]>0)count++;
else break;
i++;
}
cout<<"Case "<<++j<<": "<0)
count++;
}
if(sum>q)i--;
cout<<"Case "<<++j<<": "<<count<<endl;
}
}
}
}
please help me by finding out a test case that may give wrong ans of this problem. i couldnt find such case. but im having wrong ans frequently .