Submission #961679

#TimeUsernameProblemLanguageResultExecution timeMemory
961679UnforgettableplElection Campaign (JOI15_election_campaign)C++17
10 / 100
43 ms8804 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int modulo = 1e9+7; int DP[100001]; vector<pair<int,int>> transitions[100001]; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,m; cin >> n; for(int i=1;i<n;i++)cin>>m>>m; cin >> m; for(int i=1;i<=m;i++){ int a,b,c;cin>>a>>b>>c; if(a>b)swap(a,b); transitions[b].emplace_back(a-1,c); } for(int i=1;i<=n;i++){ DP[i] = DP[i-1]; for(auto&x:transitions[i])DP[i]=max(DP[i],x.second+DP[x.first]); } cout << DP[n] << '\n'; }
#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...