# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1037068 | vjudge1 | 거래 (IZhO13_trading) | C++17 | 2083 ms | 1520 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define bug(...) __f (#__VA_ARGS__, __VA_ARGS__)
// #define int long long
#define F first
#define S second
#define pb push_back
#define vi vector <long long>
#define pii pair <long long, long long>
#define vpi vector <pii>
#define vpp vector <pair <long long, pii>>
#define mii map <long long, long long>
#define mpi map <pii, long long>
#define spi set <pii>
#define endl "\n"
#define sz(x) ((long long) x.size())
#define all(p) p.begin(), p.end()
#define double long double
#define que_max priority_queue <long long>
#define que_min priority_queue <long long, vi, greater<long long>>
#define print(a) for (auto x: a) cout << x << " "; cout << endl
#define print1(a) for (auto x: a) cout << x.F << " " << x.S << endl
#define print2(a, l, r) for (long long i = l; i < r; ++ i) cout << a[i] << " "; cout << endl
#define GET(n, id) (!!(n & (1LL << id))) // lay bit thu id
#define ON(n, id) (n | (1LL << id)) // bit thu id luon la 1
#define OFF(n, id) (n & ~(1LL << id)) // bit thu id luon la 0
#define BIT0(n, id) (n & (-1LL << (id + 1))) // chinh tat ca id bit dau thanh 0 (id >= 1)
#define BIT0IJ(n, i, j) (n & ((-1LL << (j + 1)) | ((1LL << i) - 1))) // chinh tat ca bit tu i den j thanh 0 (id = 0, 1, ...)
#define REPLACE_BIT(n, i, j, m) (BIT0IJ(n, i, j) | (m << i))
#define MSB(mask) 63 - __builtin_clzll(mask) // so bit 0 o cuoi
#define LSB(mask) __builtin_ctzll(mask) // so bit 0 o dau
#define ONE(mask) __builtin_popcountll(mask) // so bit bat
#define mem(a, b) memset(a, b, sizeof(a));
#define ff(i, l, r) for (long long i = (long long) (l); i < (long long) (r); ++ i)
#define fff(x, arr) for (auto &x: arr)
#define umii unordered_map<long long, long long>
#define np next_permutation
#define respam srand(time(NULL) * 10000000 + rand())
#define Vo_Duyen signed main()
template <typename Arg1>
void __f (const char* name, Arg1 && arg1) {cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* name, Arg1 && arg1, Args && ... args) {
const char* comma = strchr (name + 1, ',');
cout.write (name, comma - name) << " : " << arg1 << " | "; __f (comma + 1, args ...);
}
struct pair_hair {size_t operator()(const pii &p) const {return hash<int>()(p.F) ^ hash<int>()(p.S);}};
// const int mod = 1e8 + 7;
const int mod = 3e5 + 3, mod1 = 1e4, mod2 = 82;
int n, m;
int st[mod * 4];
void ud(int id, int l, int r, int i, int u) {
if (l > r || i < l || i > r) return;
if (l == r) {
st[id] = max(u, st[id]);
return;
}
int m = l + r >> 1;
ud(id << 1, l, m, i, u);
ud(id << 1 | 1, m + 1, r, i, u);
st[id] = max(st[id << 1], st[id << 1 | 1]);
}
int get(int id, int l, int r, int u, int v) {
if (r < u || l > v) return 0;
if (u <= l && r <= v) return st[id];
int m = l + r >> 1;
return max(get(id << 1, l, m, u, v), get(id << 1 | 1, m + 1, r, u, v));
}
void solve() {
cin >> n >> m;
while (m --) {
int l, r, x;
cin >> l >> r >> x;
ff(i, 0, r - l + 1) ud(1, 1, n, l + i, x + i);
}
ff(i, 0, n) cout << get(1, 1, n, i + 1, i + 1) << " ";
return;
}
Vo_Duyen {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t = 1;
// cin >> t;
while (t --) solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |