Language: C++

#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

typedef vector<vector<int>> graph;

// SCC Strongly Connected Component 強連結成分分解
struct SCC {
	int V;
	int cV;
	graph G;
	graph cG;
	vector<int> cmp;
	vector<int> vs;
	vector<bool> used;
	vector<vector<int>> nodes;

	SCC(int V_):V(V_), G(V_), cmp(V_), used(V_) {}
	SCC(const graph &G_):V(G_.size()), G(G_), cmp(V), used(V) {}

	void add_edge(int from, int to) {
		G[from].emplace_back(to);
	}

	void dfs(int v) {
		used[v] = true;
		for(const auto &to : G[v]) {
			if(!used[to]) dfs(to);
		}
		vs.emplace_back(v);
	}

	void rdfs(int v, int k, graph &rG) {
		used[v] = true;
		cmp[v] = k;
		for(const auto &to : rG[v]) {
			if(!used[to]) rdfs(to, k, rG);
		}
	}

	int scc() {
		vs.clear();
		fill(used.begin(), used.end(), false);

		for(int v = 0; v < V; ++v) {
			if(!used[v]) dfs(v);
		}

		graph rG(V);
		for(int v = 0; v < V; ++v) {
			for(const auto &to : G[v]) {
				rG[to].emplace_back(v);
			}
		}

		fill(used.begin(), used.end(), false);
		int k = 0;
		for(int i = static_cast<int>(vs.size()) - 1; i >= 0; --i) {
			if(!used[vs[i]]) rdfs(vs[i], k++, rG);
		}
		return k;
	}

	void construct() {
		cV = scc();
		cG.clear();
		cG.resize(cV);
		nodes.resize(cV);

		for(int v = 0; v < V; ++v) {
			nodes[cmp[v]].emplace_back(v);
			for(const auto &to : G[v]) {
				if(cmp[v] != cmp[to]) cG[cmp[v]].emplace_back(cmp[to]);
			}
		}

		for(auto &es : cG) {
			sort(es.begin(), es.end());
			es.erase(unique(es.begin(), es.end()), es.end());
		}
	}
};

constexpr int MAX_N = 100;
constexpr int MAX_T = 10000;

int p[MAX_N];
int t[MAX_N];
int k[MAX_N];
bool selfloop[MAX_N];
int local_score[MAX_N][MAX_T + 1];

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	for(int N, M, T; cin >> N >> M >> T && N;) {
		for(int i = 0; i < N; ++i) {
			cin >> p[i] >> t[i] >> k[i];
		}

		memset(selfloop, false, sizeof(selfloop));

		SCC scc(N);
		for(int i = 0; i < M; ++i) {
			int a, b;
			cin >> a >> b;

			if(a == b) {
				selfloop[a - 1] = true;
			}
			else {
				scc.add_edge(a - 1, b - 1);
			}
		}

		scc.construct();

		vector<int> in(scc.cV, 0);
		for(const auto &edges : scc.cG) {
			for(const auto &to : edges) {
				++in[to];
			}
		}

		queue<int> que;
		for(int v = 0; v < scc.cV; ++v) {
			if(in[v] == 0) que.insert(v);
		}
		memset(local_score, 0, sizeof(local_score));

		int ans = 0;
		while(!que.empty()) {
			const int v = que.front();
			que.pop();

			auto &dp = local_score[v];

			if(scc.nodes[v].size() == 1 && !selfloop[scc.nodes[v].front()]) {
				const int cv = scc.nodes[v].front();

				for(int i = T - t[cv]; i >= 0; --i) {
					chmax(dp[i + t[cv]], dp[i] + p[cv]);
				}
			}
			else {
				for(const auto &cv : scc.nodes[v]) {
					int num = k[cv];

					for(int j = 1; num > 0; j <<= 1) {

						const int mul = min(num, j);
						num -= mul;

						for(int i = T - mul * t[cv]; i >= 0; --i) {
							chmax(dp[i + mul * t[cv]], dp[i] + mul * p[cv]);
						}
					}
				}
			}

			chmax(ans, *max_element(dp, dp + T + 1));

			for(const auto &to : scc.cG[v]) {
				for(int i = 0; i <= T; ++i) {
					chmax(local_score[to][i], dp[i]);
				}
				if(--in[to] == 0) que.insert(to);
			}
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:134:44: error: 'class std::queue<int>' has no member named 'insert'
  134 |                         if(in[v] == 0) que.insert(v);
      |                                            ^~~~~~
a.cc:174:55: error: 'class std::queue<int>' has no member named 'insert'
  174 |                                 if(--in[to] == 0) que.insert(to);
      |                                                       ^~~~~~