// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define eb emplace_back
#define m1(x) template<class T, class... U> void x(T&& a, U&&... b)
#define m2(x) (ll[]){(x forward<U>(b),0)...}
m1(pr){cout << forward<T>(a); m2(cout << " " <<); cout << "\n";}
m1(re){cin >> forward<T>(a); m2(cin >>);}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ll n, m, k;
re(n, m, k);
vector<ll> parent(n+1);
for (ll i = 2; i <= n; i++) re(parent[i]);
vector<pair<ll,ll>> fruits;
for (ll i = 0; i < m; i++) {
ll v, d, w;
re(v, d, w);
fruits.eb(v, d);
}
sort(fruits.begin(), fruits.end(), [&](auto &x, auto &y) {
if (x.second != y.second) return x.second > y.second;
return x.first > y.first;
});
ll ans = 0;
ll cutb4 = k + 1;
for (auto pr:fruits) {
ll v = pr.first, d = pr.second;
if (d < cutb4) {
ans++;
cutb4 = d;
}
}
pr(ans);
}
| # | 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... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |