Submission #973376

# Submission time Handle Problem Language Result Execution time Memory
973376 2024-05-01T21:12:24 Z shezitt Election Campaign (JOI15_election_campaign) C++14
10 / 100
114 ms 8944 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <queue>
#include <set>

using namespace std;

using ll = long long;

#define int ll
#define fore(a, b, c) for(int a=b; a<c; ++a)
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define ii pair<int,int>
#define F first
#define S second

const int N = 1e5+5;

int n, m;

vector<ii> adj[N];

int dp[N];

// linea

signed main(){

    cin >> n;

    fore(i, 1, n){
        int u, v;
        cin >> u >> v;
    }

    cin >> m;

    fore(i, 0, m){
        int a, b, c;
        cin >> a >> b >> c;
        adj[min(a,b)].push_back({max(a,b),c});
    }

    for(int i=n-1; i>0; --i){

        dp[i] = dp[i+1];

        if(sz(adj[i]) == 0) continue;

        for(auto xx : adj[i]){
            dp[i] = max(dp[i], dp[xx.F + 1] + xx.S);
        }

    }

    cout << dp[1];

}   
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3164 KB Output is correct
2 Correct 1 ms 3384 KB Output is correct
3 Incorrect 1 ms 3164 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3160 KB Output is correct
2 Correct 1 ms 3160 KB Output is correct
3 Correct 2 ms 3164 KB Output is correct
4 Correct 94 ms 8332 KB Output is correct
5 Correct 101 ms 8356 KB Output is correct
6 Correct 92 ms 8532 KB Output is correct
7 Correct 99 ms 8464 KB Output is correct
8 Correct 94 ms 8344 KB Output is correct
9 Correct 96 ms 8608 KB Output is correct
10 Correct 94 ms 8568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3160 KB Output is correct
2 Correct 1 ms 3160 KB Output is correct
3 Correct 2 ms 3164 KB Output is correct
4 Correct 94 ms 8332 KB Output is correct
5 Correct 101 ms 8356 KB Output is correct
6 Correct 92 ms 8532 KB Output is correct
7 Correct 99 ms 8464 KB Output is correct
8 Correct 94 ms 8344 KB Output is correct
9 Correct 96 ms 8608 KB Output is correct
10 Correct 94 ms 8568 KB Output is correct
11 Correct 12 ms 4184 KB Output is correct
12 Correct 109 ms 8944 KB Output is correct
13 Correct 106 ms 8784 KB Output is correct
14 Correct 101 ms 8788 KB Output is correct
15 Correct 99 ms 8716 KB Output is correct
16 Correct 114 ms 8712 KB Output is correct
17 Correct 99 ms 8848 KB Output is correct
18 Correct 99 ms 8604 KB Output is correct
19 Correct 101 ms 8788 KB Output is correct
20 Correct 100 ms 8840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 106 ms 8332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3164 KB Output is correct
2 Correct 1 ms 3384 KB Output is correct
3 Incorrect 1 ms 3164 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3164 KB Output is correct
2 Correct 1 ms 3384 KB Output is correct
3 Incorrect 1 ms 3164 KB Output isn't correct
4 Halted 0 ms 0 KB -