답안 #776440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
776440 2023-07-07T22:12:37 Z Hacv16 Election Campaign (JOI15_election_campaign) C++17
10 / 100
65 ms 49908 KB
#include <bits/stdc++.h>
using namespace std;
 
const int LOG = 21;
const int MAX = 2e6 + 15;
 
int n, m, dp[MAX];
vector<pair<int, int>> queries[MAX];
 
int32_t main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 
	cin >> n;
 
	for(int i = 1; i < n; i++){
		int u, v; cin >> u >> v;
	}
	
	cin >> m;
 
	while(m--){
		int u, v, w; cin >> u >> v >> w;
		if(u > v) swap(u, v);
		queries[v].emplace_back(u, w);
	}	

	for(int i = 1; i <= n; i++){
		dp[i] = dp[i - 1];

		for(auto [j, w] : queries[i])
			dp[i] = max(dp[i], dp[j - 1] + w);
	}

	cout << dp[n] << '\n';	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 47188 KB Output is correct
2 Correct 21 ms 47188 KB Output is correct
3 Incorrect 20 ms 47168 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 47268 KB Output is correct
2 Correct 20 ms 47188 KB Output is correct
3 Correct 20 ms 47188 KB Output is correct
4 Correct 57 ms 49208 KB Output is correct
5 Correct 54 ms 49676 KB Output is correct
6 Correct 54 ms 49696 KB Output is correct
7 Correct 58 ms 49704 KB Output is correct
8 Correct 55 ms 49668 KB Output is correct
9 Correct 58 ms 49812 KB Output is correct
10 Correct 55 ms 49736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 47268 KB Output is correct
2 Correct 20 ms 47188 KB Output is correct
3 Correct 20 ms 47188 KB Output is correct
4 Correct 57 ms 49208 KB Output is correct
5 Correct 54 ms 49676 KB Output is correct
6 Correct 54 ms 49696 KB Output is correct
7 Correct 58 ms 49704 KB Output is correct
8 Correct 55 ms 49668 KB Output is correct
9 Correct 58 ms 49812 KB Output is correct
10 Correct 55 ms 49736 KB Output is correct
11 Correct 31 ms 47920 KB Output is correct
12 Correct 56 ms 49664 KB Output is correct
13 Correct 56 ms 49764 KB Output is correct
14 Correct 65 ms 49740 KB Output is correct
15 Correct 64 ms 49764 KB Output is correct
16 Correct 57 ms 49728 KB Output is correct
17 Correct 62 ms 49748 KB Output is correct
18 Correct 55 ms 49732 KB Output is correct
19 Correct 65 ms 49908 KB Output is correct
20 Correct 59 ms 49740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 49164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 47188 KB Output is correct
2 Correct 21 ms 47188 KB Output is correct
3 Incorrect 20 ms 47168 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 47188 KB Output is correct
2 Correct 21 ms 47188 KB Output is correct
3 Incorrect 20 ms 47168 KB Output isn't correct
4 Halted 0 ms 0 KB -