WA for Pintu and Fruits, can't find why, help!

getting wrong answer for Pintu and Fruits can’t find the error, please, help!

#include <iostream>
#include <cstring>
#include <climits>
using namespace std;

int main(){
    int t,m,n;
    long long int temp, min, f[50],type_price[50];

    cin >> t;
    while(t--){
        cin >> n >> m;
        min = LLONG_MAX;
        memset(type_price, -1, sizeof(type_price));
        for (int i = 0; i < n; i++){
            cin >> f[i];
            f[i]--;
        }

        for (int i=0; i<n; i++){
            cin >> temp;
            if (type_price[f[i]] == -1)
                type_price[f[i]]++;
            type_price[f[i]] += temp;
        }

        for (int i=0; i<n; i++)
            if (type_price[i] < min && type_price[i] != -1)
                min = type_price[i];

        cout << min << endl;
    }
    return 0;
}

Your edited code : here

Line : 29

N will be 50, as you got to check for every fruit in this case. :slight_smile:

1 Like

Thank you!