Submission #565302

# Submission time Handle Problem Language Result Execution time Memory
565302 2022-05-20T16:07:49 Z SSRS Election Campaign (JOI15_election_campaign) C++14
10 / 100
141 ms 10464 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<vector<int>> E(N);
  for (int i = 0; i < N - 1; i++){
    int X, Y;
    cin >> X >> Y;
  }
  int M;
  cin >> M;
  vector<int> A(M), B(M), C(M);
  for (int i = 0; i < M; i++){
    cin >> A[i] >> B[i] >> C[i];
    if (A[i] > B[i]){
      swap(A[i], B[i]);
    }
    A[i]--;
  }
  vector<vector<int>> R(N + 1);
  for (int i = 0; i < M; i++){
    R[B[i]].push_back(i);
  }
  vector<int> dp(N + 1, 0);
  for (int i = 1; i <= N; i++){
    dp[i] = dp[i - 1];
    for (int j : R[i]){
      dp[i] = max(dp[i], dp[A[j]] + C[j]);
    }
  }
  cout << dp[N] << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 132 ms 7652 KB Output is correct
5 Correct 126 ms 7652 KB Output is correct
6 Correct 122 ms 7656 KB Output is correct
7 Correct 125 ms 7652 KB Output is correct
8 Correct 130 ms 7640 KB Output is correct
9 Correct 119 ms 7652 KB Output is correct
10 Correct 118 ms 7640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 132 ms 7652 KB Output is correct
5 Correct 126 ms 7652 KB Output is correct
6 Correct 122 ms 7656 KB Output is correct
7 Correct 125 ms 7652 KB Output is correct
8 Correct 130 ms 7640 KB Output is correct
9 Correct 119 ms 7652 KB Output is correct
10 Correct 118 ms 7640 KB Output is correct
11 Correct 15 ms 720 KB Output is correct
12 Correct 136 ms 10320 KB Output is correct
13 Correct 133 ms 10332 KB Output is correct
14 Correct 130 ms 10324 KB Output is correct
15 Correct 137 ms 10464 KB Output is correct
16 Correct 141 ms 10392 KB Output is correct
17 Correct 132 ms 10340 KB Output is correct
18 Correct 131 ms 10304 KB Output is correct
19 Correct 135 ms 10324 KB Output is correct
20 Correct 130 ms 10316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 139 ms 7756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -