# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1116260 | Tsagana | Trading (IZhO13_trading) | C++14 | 1 ms | 2384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second
using namespace std;
multiset<int> s;
int a[300001];
int b[300001];
void solve () {
int n, m; cin >> n >> m;
for (int i = 1; i <= m; i++) {
int l, r, k; cin >> l >> r >> k;
int x = k - l;
a[l] = b[r] = x;
}
for (int i = 1; i <= n; i++) {
if (a[i]) s.insert(a[i]);
cout << (s.empty() ? 0 : i + *s.begin()) << ' ';
if (b[i] && !s.empty()) {
auto x = s.find(b[i]);
if(x == s.end()) continue;
s.erase(x);
}
}
}
signed main() {IOS solve(); return 0;}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |