Submission #1078534

#TimeUsernameProblemLanguageResultExecution timeMemory
1078534avighnaArcade (NOI20_arcade)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> typedef long long ll; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); ll n, m; std::cin >> n >> m; std::vector<ll> t(m), a(m); for (auto &i : t) { std::cin >> i; } for (auto &i : a) { std::cin >> i; } std::vector<std::vector<ll>> adj(n); std::vector<ll> indeg(n), outdeg(n); for (ll i = 0; i < n; ++i) { for (ll j = 0; j < n; ++j) { if (i == j) { continue; } if (std::abs(a[i] - a[j]) <= std::abs(t[i] - t[j])) { adj[i].push_back(j); outdeg[i]++, indeg[j]++; } } } std::function<ll(ll)> dfs; dfs = [&](ll node) { ll ans = 0; for (auto &i : adj[node]) { ans += dfs(i); } return std::max(ans, 1LL); }; ll ans = 0; for (ll i = 0; i < n; ++i) { if (indeg[i] == 0) { ans += dfs(i); } } std::cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...