# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1027617 | KasymK | Fireworks (APIO16_fireworks) | C++17 | 2 ms | 3004 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"
using namespace std;
#define ss second
#define ff first
#define ll long long
#define pb push_back
#define all(v) v.begin(), v.end()
#define pii pair<int, int>
const int N = 1e5+5;
vector<pii> adj[N];
int par[N];
int main(){
int n, m;
scanf("%d%d", &n, &m);
for(int i = 2; i <= n+m; ++i){
int a, b;
scanf("%d%d", &a, &b);
par[i] = a;
adj[a].pb({i,b});
}
int x = 1;
auto cmp = [&](pii a, pii b) -> bool {
return a.ss < b.ss;
};
sort(all(adj[x]), cmp);
int sz = (int)adj[x].size();
int ad = adj[x][sz/2].ss;
ll answer = 0;
for(auto i : adj[x])
answer += abs(ad-i.ss);
printf("%lld", answer);
return 0;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |