#include using namespace std; #define MAXN 10000 int In[MAXN], Out[MAXN], Cost[MAXN], I[MAXN], St[MAXN]; int main() { int n, sz = 0; cin>>n; for(int i=1; i<=n; i++) { cin>>Out[i]>>In[i]>>Cost[i]; I[i] = i; } sort(I+1, I+n+1, [](int a, int b) {return In[a] > In[b];}); int total = 0; for(int i=1; i<=n; i++) { int cur = I[i]; int choose = -1, best = 20000000; for(int j=1; j<=sz; j++) { if(In[St[j]] <= Out[cur]) continue; if(best > (In[St[j]] - Out[cur]) * Cost[St[j]]) { best = (In[St[j]] - Out[cur]) * Cost[St[j]]; choose = j; } } if(choose == -1) { St[++sz] = cur; } else { total += best; St[choose] = cur; } } for(int i=1; i<=sz; i++) { total += In[St[i]] * Cost[St[i]]; } cout<