#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define u_map unordered_map
#define int ll
const int maxn = 1e5 + 5, mod = 1e9 + 7;
vector<int> adj[maxn];
int d[maxn], w[maxn], ans, dp[maxn];
map<int, int> cnt;
bool issub = true;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, m, k;
cin >> n >> m >> k;
for (int i = 2; i <= n; i++) {
int p;
cin >> p;
if (p != i - 1) {
issub = false;
}
adj[p].pb(i);
}
for (int i = 1; i <= m; i++) {
int _v, _d, _w;
cin >> _v >> _d >> _w;
d[_v] = _d;
w[_v] = _w;
ans += _w;
}
if (issub) {
for (int i = n; i >= 1; i--) {
cnt[d[i]]++;
if (i == n) {
dp[i] = d[i] == 0 ? 0 : 1;
continue;
}
dp[i] = max(dp[i + 1], d[i] == 0 ? 0 : cnt[d[i]]);
}
cout << dp[1];
return 0;
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
6492 KB |
Output is correct |
2 |
Correct |
14 ms |
7516 KB |
Output is correct |
3 |
Correct |
31 ms |
6484 KB |
Output is correct |
4 |
Correct |
22 ms |
5848 KB |
Output is correct |
5 |
Correct |
27 ms |
6236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4956 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
6832 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
5212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |