Buongiorno, qualcuno riuscirebbe a capire dov’è l’errore? Prendo 80/100 perchè sbaglio i test 2 e 4
#include <iostream>
#include <vector>
#define DIM 30
using namespace std;
vector<pair<int,int>> adj[DIM];
int ncrediti[DIM];
int n,k;
int minOre=2e9;
void dfs(int nodo,int c,int h){
if(c>=k){
if(h<minOre)
minOre=h;
}else{
for(int i=0;i<adj[nodo].size();i++)
dfs(adj[nodo][i].first,c+ncrediti[adj[nodo][i].first],h+adj[nodo][i].second);
}
}
int main(){
freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
cin>>k>>n;
int i,j;
for(i=0;i<n;i++)
cin>>ncrediti[i];
for(i=0;i<n;i++){
for(j=0;j<n;j++){
int temp;
cin>>temp;
if(temp!=0)
adj[i].push_back({j,temp});
}
}
for(i=0;i<n;i++)
dfs(i,ncrediti[i],0);
cout<<minOre;
}