Submission #973376

#TimeUsernameProblemLanguageResultExecution timeMemory
973376shezittElection Campaign (JOI15_election_campaign)C++14
10 / 100
114 ms8944 KiB
#include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <cassert> #include <queue> #include <set> using namespace std; using ll = long long; #define int ll #define fore(a, b, c) for(int a=b; a<c; ++a) #define sz(x) (int) x.size() #define all(x) x.begin(), x.end() #define vi vector<int> #define ii pair<int,int> #define F first #define S second const int N = 1e5+5; int n, m; vector<ii> adj[N]; int dp[N]; // linea signed main(){ cin >> n; fore(i, 1, n){ int u, v; cin >> u >> v; } cin >> m; fore(i, 0, m){ int a, b, c; cin >> a >> b >> c; adj[min(a,b)].push_back({max(a,b),c}); } for(int i=n-1; i>0; --i){ dp[i] = dp[i+1]; if(sz(adj[i]) == 0) continue; for(auto xx : adj[i]){ dp[i] = max(dp[i], dp[xx.F + 1] + xx.S); } } cout << dp[1]; }
#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...