Submission #641566

#TimeUsernameProblemLanguageResultExecution timeMemory
641566andecaandeciZagrade (COI20_zagrade)C++17
0 / 100
3 ms4944 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2e5 + 5; vector<int> g[N]; int a[N], n, m; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> n >> m; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < m; i++) { int u, v; cin >> u >> v; u--, v--; g[u].push_back(v); g[v].push_back(u); } for(int i = 0; i < n; i++) { ll cur = a[i], cnt = 0; priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q; q.push({a[i], i}); vector<bool> vis(n); vis[i] = 1; while(!q.empty()) { auto [val, v] = q.top(); q.pop(); if(v != i) { if(cur < val) { break; } else { cur += val; } } cnt++; for(auto u : g[v]) { if(!vis[u]) { vis[u] = 1; q.push({a[u], u}); } } } cout << (cnt == n ? '1' : '0'); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...