# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1027617 | 2024-07-19T08:00:22 Z | KasymK | Fireworks (APIO16_fireworks) | C++17 | 2 ms | 3004 KB |
#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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2904 KB | Output is correct |
2 | Correct | 2 ms | 2908 KB | Output is correct |
3 | Correct | 1 ms | 2908 KB | Output is correct |
4 | Correct | 1 ms | 3000 KB | Output is correct |
5 | Correct | 1 ms | 2908 KB | Output is correct |
6 | Correct | 1 ms | 2908 KB | Output is correct |
7 | Correct | 1 ms | 3004 KB | Output is correct |
8 | Correct | 1 ms | 2908 KB | Output is correct |
9 | Correct | 1 ms | 2908 KB | Output is correct |
10 | Correct | 1 ms | 2908 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2908 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2904 KB | Output is correct |
2 | Correct | 2 ms | 2908 KB | Output is correct |
3 | Correct | 1 ms | 2908 KB | Output is correct |
4 | Correct | 1 ms | 3000 KB | Output is correct |
5 | Correct | 1 ms | 2908 KB | Output is correct |
6 | Correct | 1 ms | 2908 KB | Output is correct |
7 | Correct | 1 ms | 3004 KB | Output is correct |
8 | Correct | 1 ms | 2908 KB | Output is correct |
9 | Correct | 1 ms | 2908 KB | Output is correct |
10 | Correct | 1 ms | 2908 KB | Output is correct |
11 | Incorrect | 1 ms | 2908 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2904 KB | Output is correct |
2 | Correct | 2 ms | 2908 KB | Output is correct |
3 | Correct | 1 ms | 2908 KB | Output is correct |
4 | Correct | 1 ms | 3000 KB | Output is correct |
5 | Correct | 1 ms | 2908 KB | Output is correct |
6 | Correct | 1 ms | 2908 KB | Output is correct |
7 | Correct | 1 ms | 3004 KB | Output is correct |
8 | Correct | 1 ms | 2908 KB | Output is correct |
9 | Correct | 1 ms | 2908 KB | Output is correct |
10 | Correct | 1 ms | 2908 KB | Output is correct |
11 | Incorrect | 1 ms | 2908 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |