답안 #419589

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
419589 2021-06-07T09:58:16 Z tengiz05 Election Campaign (JOI15_election_campaign) C++17
10 / 100
89 ms 10552 KB
#include <bits/stdc++.h>
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n, m;
    std::cin >> n;
    std::vector<std::vector<int>> e(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        std::cin >> u >> v;
        u--;
        v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    std::cin >> m;
    std::vector<std::vector<std::pair<int, int>>> q(n + 1);
    for (int i = 0; i < m; i++) {
        int u, v, c;
        std::cin >> u >> v >> c;
        if (u > v) std::swap(u, v);
        q[v].emplace_back(u, c);
    }
    std::vector<int> dp(n + 1);
    for (int i = 1; i <= n; i++) {
        dp[i] = dp[i - 1];
        for (auto [j, c] : q[i]) {
            dp[i] = std::max(dp[i], dp[j - 1] + c);
        }
    }
    std::cout << dp[n] << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 73 ms 10068 KB Output is correct
5 Correct 73 ms 10316 KB Output is correct
6 Correct 89 ms 10448 KB Output is correct
7 Correct 69 ms 10392 KB Output is correct
8 Correct 72 ms 10464 KB Output is correct
9 Correct 75 ms 10400 KB Output is correct
10 Correct 69 ms 10312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 73 ms 10068 KB Output is correct
5 Correct 73 ms 10316 KB Output is correct
6 Correct 89 ms 10448 KB Output is correct
7 Correct 69 ms 10392 KB Output is correct
8 Correct 72 ms 10464 KB Output is correct
9 Correct 75 ms 10400 KB Output is correct
10 Correct 69 ms 10312 KB Output is correct
11 Correct 8 ms 972 KB Output is correct
12 Correct 71 ms 10376 KB Output is correct
13 Correct 71 ms 10372 KB Output is correct
14 Correct 89 ms 10468 KB Output is correct
15 Correct 87 ms 10288 KB Output is correct
16 Correct 73 ms 10552 KB Output is correct
17 Correct 72 ms 10308 KB Output is correct
18 Correct 70 ms 10308 KB Output is correct
19 Correct 71 ms 10388 KB Output is correct
20 Correct 89 ms 10296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 77 ms 10180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -