# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
916612 | Tuanlinh123 | Worst Reporter 4 (JOI21_worst_reporter4) | C++11 | 351 ms | 109744 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 ll long long
#define pll pair<ll, ll>
#define fi first
#define se second
using namespace std;
const ll maxn=200005;
ll A[maxn], H[maxn], C[maxn], deg[maxn];
map<ll, ll> cnt[maxn];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n, sum=0; cin >> n;
for (ll i=1; i<=n; i++)
cin>>A[i]>>H[i]>>C[i], sum+=C[i], deg[A[i]]++;
queue <ll> q;
for (ll i=1; i<=n; i++)
if (!deg[i]) q.push(i);
auto Merge=[&](map<ll, ll> &a, map<ll, ll> &b)
{
if (a.size()<b.size()) swap(a, b);
for (pll i:b) a[i.fi]+=i.se;
};
auto Fix=[&](map<ll, ll> &a, ll H, ll C)
{
a[H]+=C; auto it=a.lower_bound(H);
while (it!=a.begin())
{
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |