# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
46428 | RezwanArefin01 | Election Campaign (JOI15_election_campaign) | C++17 | 151 ms | 53084 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int maxn = 1e5 + 10;
vector<int> adj[maxn];
vector<ii> q[maxn];
ll dp[maxn]; int n, m;
void solve23() {
for(int i = 1; i <= n; i++) {
dp[i] = dp[i - 1];
for(auto it : q[i]) {
dp[i] = max(dp[i], dp[it.first - 1] + it.second);
}
}
printf("%lld\n", dp[n]);
exit(0);
}
int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
freopen("in", "r", stdin);
#endif
scanf("%d", &n);
bool subtask23 = 1;
for(int i = 1; i < n; i++) {
int u, v; scanf("%d %d", &u, &v);
subtask23 &= (u == i && v == u + 1);
adj[u].push_back(v);
adj[v].push_back(u);
}
scanf("%d", &m);
for(int i = 0; i < m; i++) {
int x, y, c;
scanf("%d %d %d", &x, &y, &c);
if(x > y) swap(x, y);
q[y].emplace_back(x, c);
}
if(subtask23) solve23();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |