# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1068114 | 2024-08-21T07:47:01 Z | 김은성(#11126) | Paths (RMI21_paths) | C++17 | 600 ms | 12996 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200009; typedef long long ll; vector<pair<int, ll> > graph[MAXN]; bool ch[MAXN]; priority_queue<ll> settree(int v){ ch[v] = 1; priority_queue<ll> ret; for(auto [u, c]: graph[v]){ if(ch[u]) continue; priority_queue<ll> q = settree(u); ll temp = q.top() + c; q.pop(); q.push(temp); if(ret.size() < q.size()) swap(ret, q); while(!q.empty()){ ret.push(q.top()); q.pop(); } } ret.push(0); return ret; } int main(){ int n, k, i, j, a, b; ll c; scanf("%d %d", &n, &k); for(i=1; i<n; i++){ scanf("%d %d %lld", &a, &b, &c); graph[a].push_back(make_pair(b, c)); graph[b].push_back(make_pair(a, c)); } for(int r=1; r<=n; r++){ memset(ch, 0, sizeof(ch)); priority_queue<ll> ret = settree(r); ll ans = 0; for(i=1; i<=k; i++){ ans += ret.top(); ret.pop(); } printf("%lld\n", ans); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 5212 KB | Output is correct |
2 | Correct | 2 ms | 5212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 5212 KB | Output is correct |
2 | Correct | 2 ms | 5212 KB | Output is correct |
3 | Correct | 4 ms | 5212 KB | Output is correct |
4 | Correct | 4 ms | 5212 KB | Output is correct |
5 | Correct | 5 ms | 5212 KB | Output is correct |
6 | Correct | 4 ms | 5124 KB | Output is correct |
7 | Correct | 4 ms | 5212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 5212 KB | Output is correct |
2 | Correct | 2 ms | 5212 KB | Output is correct |
3 | Correct | 4 ms | 5212 KB | Output is correct |
4 | Correct | 4 ms | 5212 KB | Output is correct |
5 | Correct | 5 ms | 5212 KB | Output is correct |
6 | Correct | 4 ms | 5124 KB | Output is correct |
7 | Correct | 4 ms | 5212 KB | Output is correct |
8 | Correct | 77 ms | 5208 KB | Output is correct |
9 | Correct | 65 ms | 5468 KB | Output is correct |
10 | Correct | 58 ms | 5424 KB | Output is correct |
11 | Correct | 52 ms | 5208 KB | Output is correct |
12 | Correct | 57 ms | 5208 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 5212 KB | Output is correct |
2 | Correct | 2 ms | 5212 KB | Output is correct |
3 | Correct | 4 ms | 5212 KB | Output is correct |
4 | Correct | 4 ms | 5212 KB | Output is correct |
5 | Correct | 5 ms | 5212 KB | Output is correct |
6 | Correct | 4 ms | 5124 KB | Output is correct |
7 | Correct | 4 ms | 5212 KB | Output is correct |
8 | Correct | 77 ms | 5208 KB | Output is correct |
9 | Correct | 65 ms | 5468 KB | Output is correct |
10 | Correct | 58 ms | 5424 KB | Output is correct |
11 | Correct | 52 ms | 5208 KB | Output is correct |
12 | Correct | 57 ms | 5208 KB | Output is correct |
13 | Correct | 450 ms | 5484 KB | Output is correct |
14 | Correct | 330 ms | 5468 KB | Output is correct |
15 | Correct | 224 ms | 5468 KB | Output is correct |
16 | Correct | 248 ms | 5448 KB | Output is correct |
17 | Correct | 308 ms | 5464 KB | Output is correct |
18 | Correct | 183 ms | 5508 KB | Output is correct |
19 | Correct | 471 ms | 5464 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1044 ms | 12996 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 5212 KB | Output is correct |
2 | Correct | 2 ms | 5212 KB | Output is correct |
3 | Correct | 4 ms | 5212 KB | Output is correct |
4 | Correct | 4 ms | 5212 KB | Output is correct |
5 | Correct | 5 ms | 5212 KB | Output is correct |
6 | Correct | 4 ms | 5124 KB | Output is correct |
7 | Correct | 4 ms | 5212 KB | Output is correct |
8 | Correct | 77 ms | 5208 KB | Output is correct |
9 | Correct | 65 ms | 5468 KB | Output is correct |
10 | Correct | 58 ms | 5424 KB | Output is correct |
11 | Correct | 52 ms | 5208 KB | Output is correct |
12 | Correct | 57 ms | 5208 KB | Output is correct |
13 | Correct | 450 ms | 5484 KB | Output is correct |
14 | Correct | 330 ms | 5468 KB | Output is correct |
15 | Correct | 224 ms | 5468 KB | Output is correct |
16 | Correct | 248 ms | 5448 KB | Output is correct |
17 | Correct | 308 ms | 5464 KB | Output is correct |
18 | Correct | 183 ms | 5508 KB | Output is correct |
19 | Correct | 471 ms | 5464 KB | Output is correct |
20 | Execution timed out | 1044 ms | 12996 KB | Time limit exceeded |
21 | Halted | 0 ms | 0 KB | - |