3470 {
3471 int n;
3472 cin >> n;
3473 auto sb = unordered_map<int, int>();
3474 auto tb = unordered_map<int, int>();
3475 for(int i = 0; i < n; i++) {
3476 int s;
3477 int t;
3478 int b;
3479 cin >> s >> t >> b;
3480 sb.insert(make_pair(s, b));
3481 tb.insert(make_pair(t, b));
3482 }
3484 int current = 0;
3485 for(int i = 1; i <= 1000; i++) {
3486 if(sb.count(i) == 1) {
3487 current += sb[i];
3488 } else if(tb.count(i) == 1) {
3489 current -= tb[i];
3490 }
3491 ans = max(ans, current);
3492 }
3494 return 0;
3495 }
vector< vector< int > > ans