Submission #109200

#TimeUsernameProblemLanguageResultExecution timeMemory
109200dupreezElection Campaign (JOI15_election_campaign)C++14
10 / 100
223 ms8952 KiB
#include <iostream> #include <algorithm> #include <cstring> #include <sstream> #include <map> #include <queue> #include <vector> #include <deque> #include <climits> #define scanf scanf_s #define mk make_pair #define pb push_back using namespace std; typedef long long int ll; typedef pair<ll, ll> pos; const ll MOD = 1000000007, N = 100010.; ll n, m,dp[N]; vector<pos> g[N]; int main() { cin >> n; for (int i = 0; i < n - 1; i++) { int v1, v2; cin >> v1 >> v2; } cin >> m; while (m--) { int v1, v2, v3; cin >> v1 >> v2 >> v3; if (v2 < v1)swap(v1, v2); g[v1].pb(mk(v3, v2+1)); } for (int i = 1; i <= n; i++) { dp[i] = max(dp[i], dp[i - 1]); for (int j = 0; j < g[i].size(); j++)dp[g[i][j].second] = max(dp[g[i][j].second], dp[i] + g[i][j].first); } ll ans = 0; for (int i = 1; i <= n+1; i++)ans = max(ans, dp[i]); cout << ans << endl; return 0; }

Compilation message (stderr)

election_campaign.cpp: In function 'int main()':
election_campaign.cpp:32:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < g[i].size(); j++)dp[g[i][j].second] = max(dp[g[i][j].second], dp[i] + g[i][j].first);
                   ~~^~~~~~~~~~~~~
#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...