제출 #1066990

#제출 시각아이디문제언어결과실행 시간메모리
1066990vjudge1거래 (IZhO13_trading)C++17
0 / 100
7 ms14684 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define For(i, a, b) for (int i = a; i <= b; ++i) #define RFor(i, a, b) for (int i = a; i >= b; --i) #define get_bit(bit, mask) (((mask) >> (bit)) & 1) #define set_bit(bit, mask) ((mask) | (1ll << (bit))) #define off_bit(bit, mask) ((mask) & (~(1ll << (bit)))) #define cnt_bit(mask) __builtin_popcountll(mask) #define top_bit(mask) (63 - __builtin_clzll(mask)) #define log(a) cout << #a << " = " << a << '\n' #define ii pair<int, int> #define iii tuple<int, int, int> #define iiii tuple<int, int, int, int> const int N = 3e5 + 5; const int INF = 1e18; int ans[N]; int n, m; int l[N], r[N], x[N]; vector<int> start[N], stop[N]; void GetInput() { cin >> n >> m; For(i, 1, n) cin >> l[i] >> r[i] >> x[i]; } void Rep() { For(i, 1, n) cout << ans[i] << ' '; } void Solve() { For(i, 1, n) start[l[i]].push_back(x[i] - l[i]), stop[r[i]].push_back(x[i] - l[i]); multiset<int> mts; mts.insert(-INF); For(i, 1, n) { for (int e : start[i]) mts.insert(e); ans[i] = max(0ll, *mts.rbegin() + i); for (int e : stop[i]) mts.erase(mts.find(e)); } } signed main() { #ifndef LOCAL ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #endif GetInput(); Solve(); Rep(); }
#Verdict Execution timeMemoryGrader output
Fetching results...