#include using namespace std; #define ll long long int main(){ int n, m; cin >>n >>m; int shade[n]; int FishP[m]; int Nshade[m]; int Yshade[m]; int Dist[m]; int tot=0; int move=0; for(int i=0; i> shade[i]; } for(int i=0; i> FishP[i] >> Nshade[i] >> Yshade[i]; } for(int i=0; iabs(shade[j]-FishP[i])){ Dist[i]=abs(shade[j]-FishP[i]); } else if(abs(shade[j]-FishP[i])==0){ Dist[i]=abs(shade[j]-FishP[i]); break; } else{ break; } } if(Dist[i]<(Yshade[i]-Nshade[i])){ move+=Dist[i]; tot+=Yshade[i]; } else{ tot+=Nshade[i]; } } cout << tot-move; return 0; }