FFL - Editorial

bro i have commented that line it will not print anything

I don’t understand why I am getting wrong answer for this. Can somebody please help?

#include <bits/stdc++.h>
using namespace std;

int main() {
int t; int n; int s; int curr; int f_min; int d_min;
cin >> t;

while(t>0) {
	cin >> n >> s;
	if(n <= 1) {
		cout << "no" << endl;
		t--;
		continue;
	}
	int P[n];
	f_min = INT_MAX;
	d_min = INT_MAX;

	for(int i=0; i<n; i++) {
		cin >> P[i];
	}
	for(int i=0; i<n; i++) {
		cin >> curr;
		if(curr == 0 && P[i] < d_min) {
			d_min = P[i];
		}
		else if(curr == 1 && P[i] < f_min) {
			f_min = P[i];
		}
	}

	if(d_min + f_min + s <= 100) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}

	t--;
}
return 0;
}

1
4 90
3 8 6 5
1 1 1 1
your code is getting wrong for above case .If they given only one type of player .then your code should give “no”. but it is giving yes.

If they only give one type of player then either of f_min or d_min should remain INT_MAX. So shouldn’t the final sum remain greater than 100?

But according to the question you have to select both players .The final sum should not be greater than 100.

I understand how INT_MAX fails, since if either of f_min or d_min is equal to INT_MAX, then the sum d_min + f_min + s would overflow.

However, say I initialize f_min and d_min to 1000 each, the test case you suggested produces the correct answer. Shouldn’t the code work fine?

Don’t take pressure my son.

for j in range(int(input())):

N,S= map(int,input().split())

L=list(map(int,input().split()))

i=list(map(int,input().split()))

p=[]

q=[]

if 0 not in i or 1 not in i:

    print("no")

else:

    for j in range(N):

        if i[j]==0:

            p.append(L[j])

        else:

            q.append(L[j])

    total=S+min(p)+min(q)

    if total<=100:

        print("yes")

    else:

        print("No")

What is wrong with this code? Showing runtime error.

Some one please explain why am i getting runtime error after getting correct answer in every possible case…
https://www.codechef.com/viewsolution/37212975

Why is it showing run time error?
T=int(input())
for i in range(T):
N,S=map(int,input().split())
P=list(map(int,input().split()))[:N]
L=list(map(int,input().split()))[:N]
A=[]
B=[]
for j in range(len(L)):
if L[j]==0:
A.append(P[j])
elif L[j]==1:
B.append(P[j])
Sum=(min(A)+min(B))
if len(A)!=0 and len(B)!=0:
if Sum<=100-S:
print(“yes”)
else:
print(“no”)
else:
print(“no”)