Submission #109200

# Submission time Handle Problem Language Result Execution time Memory
109200 2019-05-05T12:40:12 Z dupreez Election Campaign (JOI15_election_campaign) C++14
10 / 100
223 ms 8952 KB
#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

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 time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Incorrect 4 ms 2688 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2660 KB Output is correct
3 Correct 5 ms 2688 KB Output is correct
4 Correct 179 ms 7176 KB Output is correct
5 Correct 205 ms 8620 KB Output is correct
6 Correct 161 ms 8440 KB Output is correct
7 Correct 194 ms 8512 KB Output is correct
8 Correct 202 ms 8436 KB Output is correct
9 Correct 201 ms 8548 KB Output is correct
10 Correct 223 ms 8408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2660 KB Output is correct
3 Correct 5 ms 2688 KB Output is correct
4 Correct 179 ms 7176 KB Output is correct
5 Correct 205 ms 8620 KB Output is correct
6 Correct 161 ms 8440 KB Output is correct
7 Correct 194 ms 8512 KB Output is correct
8 Correct 202 ms 8436 KB Output is correct
9 Correct 201 ms 8548 KB Output is correct
10 Correct 223 ms 8408 KB Output is correct
11 Correct 24 ms 3584 KB Output is correct
12 Correct 205 ms 8760 KB Output is correct
13 Correct 199 ms 8772 KB Output is correct
14 Correct 201 ms 8952 KB Output is correct
15 Correct 196 ms 8824 KB Output is correct
16 Correct 175 ms 8824 KB Output is correct
17 Correct 167 ms 8876 KB Output is correct
18 Correct 181 ms 8696 KB Output is correct
19 Correct 198 ms 8824 KB Output is correct
20 Correct 170 ms 8696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 192 ms 7004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Incorrect 4 ms 2688 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Incorrect 4 ms 2688 KB Output isn't correct
4 Halted 0 ms 0 KB -