Submission #565302

#TimeUsernameProblemLanguageResultExecution timeMemory
565302SSRSElection Campaign (JOI15_election_campaign)C++14
10 / 100
141 ms10464 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<vector<int>> E(N); for (int i = 0; i < N - 1; i++){ int X, Y; cin >> X >> Y; } int M; cin >> M; vector<int> A(M), B(M), C(M); for (int i = 0; i < M; i++){ cin >> A[i] >> B[i] >> C[i]; if (A[i] > B[i]){ swap(A[i], B[i]); } A[i]--; } vector<vector<int>> R(N + 1); for (int i = 0; i < M; i++){ R[B[i]].push_back(i); } vector<int> dp(N + 1, 0); for (int i = 1; i <= N; i++){ dp[i] = dp[i - 1]; for (int j : R[i]){ dp[i] = max(dp[i], dp[A[j]] + C[j]); } } cout << dp[N] << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...