MCHEF - Editorial

Pls help why this is giving WA
https://www.codechef.com/viewsolution/39912666
I have used same 0-1 knapsack algo and as mentioned in editorial.
I have created a dp(i,j) where dp[i][j] represeents maximum sum of first j elements if budget is i.

Canā€™t access the setterā€™s solution.

Hi, i am a beginner, if L and R are also included then in the ans L=3 and R=4 if u remove both of those -5 AND 7 both are removed but explanation says only -5 is removed. Pls help

// MCHEF Problem - CodeChef

#include

using namespace std;

#define f(i,n) for(int i=0;i<n;i++)

#define fo(i,a,n) for(int i=a;i<n;i++)

int main(){

int t;

cin >> t;

while(t--){

    int n,k,m;

    cin >> n >> k >> m;

    int rating[n];

    f(i,n){

        cin >> rating[i];

    }

    int sum = 0;

    f(i,n){

        sum+=rating[i];

    }

    long long int l[m],r[m],c[m]; //offers

    f(i,m){

        cin>>l[i]>>r[i]>>c[i];

    }

    long long int eff;

    int max = 0;

    f(i,m){

        if(c[i]<=k){

            long long int diff = 0;

            int start = l[i];

            int end = r[i];

            for(int k=start;k<=end;k++){

                diff+=rating[k-1];

            }

            // sum-diff = effective score

            eff = sum - diff;

            if(eff>max){

                max = eff;

            }

           

        }

    }

    cout << max << endl;

}

return 0;

}