#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <array>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#define ar array
#define ll long long
#define ld long double
#define sza(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()
#define PI 3.1415926535897932384626433832795l
const int MAX_N = 1e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;
void solve() {
int n;
cin >> n;
const int A = 1e9 + 1;
int minL = A, costL = A;
int maxR = 0, costR = A;
int maxLen = 0, costLen = A;
for (int i = 0; i < n; i++)
{
int l, r, c;
cin >> l >> r >> c;
if (l < minL)
minL = l, costL = A;
if (l == minL)
costL = min(costL, c);
if (maxR < r)
maxR = r, costR = A;
if (maxR == r)
costR = min(costR, c);
if (maxLen < r - l + 1)
maxLen = r - l + 1, costLen = A;
if (maxLen == r - l + 1)
costLen = min(costLen, c);
int ans = costL + costR;
if (maxLen == maxR - minL + 1)
ans = min(ans, costLen);
cout << ans << "\n";
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int tc = 1;
cin >> tc;
for (int t = 1; t <= tc; t++) {
solve();
}
}
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |
Divisible | Three primes |
Coprimes | Cost of balloons |
One String No Trouble | Help Jarvis! |