# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1068109 | 2024-08-21T07:45:58 Z | 김은성(#11126) | Paths (RMI21_paths) | C++17 | 451 ms | 1024 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2010; const int SEGSZ = 1<<12; 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 | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 5 ms | 348 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 348 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 5 ms | 348 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 348 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 64 ms | 344 KB | Output is correct |
9 | Correct | 55 ms | 620 KB | Output is correct |
10 | Correct | 48 ms | 348 KB | Output is correct |
11 | Correct | 42 ms | 532 KB | Output is correct |
12 | Correct | 60 ms | 556 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 5 ms | 348 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 348 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 64 ms | 344 KB | Output is correct |
9 | Correct | 55 ms | 620 KB | Output is correct |
10 | Correct | 48 ms | 348 KB | Output is correct |
11 | Correct | 42 ms | 532 KB | Output is correct |
12 | Correct | 60 ms | 556 KB | Output is correct |
13 | Correct | 435 ms | 856 KB | Output is correct |
14 | Correct | 350 ms | 1024 KB | Output is correct |
15 | Correct | 205 ms | 604 KB | Output is correct |
16 | Correct | 243 ms | 600 KB | Output is correct |
17 | Correct | 303 ms | 648 KB | Output is correct |
18 | Correct | 172 ms | 600 KB | Output is correct |
19 | Correct | 451 ms | 628 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 604 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 5 ms | 348 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 348 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 64 ms | 344 KB | Output is correct |
9 | Correct | 55 ms | 620 KB | Output is correct |
10 | Correct | 48 ms | 348 KB | Output is correct |
11 | Correct | 42 ms | 532 KB | Output is correct |
12 | Correct | 60 ms | 556 KB | Output is correct |
13 | Correct | 435 ms | 856 KB | Output is correct |
14 | Correct | 350 ms | 1024 KB | Output is correct |
15 | Correct | 205 ms | 604 KB | Output is correct |
16 | Correct | 243 ms | 600 KB | Output is correct |
17 | Correct | 303 ms | 648 KB | Output is correct |
18 | Correct | 172 ms | 600 KB | Output is correct |
19 | Correct | 451 ms | 628 KB | Output is correct |
20 | Runtime error | 1 ms | 604 KB | Execution killed with signal 11 |
21 | Halted | 0 ms | 0 KB | - |