이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mxN = 110, mxK = 1010;
bool vis[mxN][mxK];
vector<pair<ll, ll>> adj[mxN];
vector<pair<ll, ll>> market[mxN];
ll N, M, K, ans;
void dfs(ll node, ll st, ll depth, ll pack, ll profit, ll time) {
if (node == st && depth && time) {
// cerr << profit << ' ' << time << endl;
return void(ans = max(ans, (ll)(profit/time)));
}
if (vis[node][pack+1])
return;
vis[node][pack+1] = 1;
if (~pack && ~market[node][pack].second) {
dfs(node, st, depth, -1, profit + market[node][pack].second, time);
}
if (!(~pack)) {
for (auto& c : adj[node]) {
for (ll i = 0; i < K; i++) {
if (~market[node][i].first)
dfs(c.first, st, depth+1, i, profit - market[node][i].first, time + c.second);
}
}
}
for (auto& c : adj[node]) {
dfs(c.first, st, depth+1, pack, profit, time + c.second);
}
}
void solve() {
cin >> N >> M >> K;
for (ll i = 1; i <= N; i++) {
for (ll j = 0; j < K; j++) {
ll b, s;
cin >> b >> s;
market[i].push_back({b, s});
}
}
for (ll i = 0; i < M; i++) {
ll u, v, t;
cin >> u >> v >> t;
adj[u].push_back({v, t});
}
for (ll i = 1; i <= N; i++) {
memset(vis, 0, sizeof vis);
dfs(i, i, 0, -1, 0, 0);
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
}
# | 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... |