#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define F first
#define S second
using namespace std;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
const int inf = 2e18;
vector<int>g[N];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin >> n >> m;
vector<int>a(n + 1);
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= m; i++) {
int u,v;
cin >> u >> v;
g[u].pb(v);
g[v].pb(u);
}
for(int i = 1; i <= n; i++) {
vector<bool>was(n + 1,false);
was[i] = true;
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;
int sum = a[i];
bool ok = true;
for(int j : g[i]) pq.push({a[j],j});
while(!pq.empty()) {
int val = pq.top().F,u = pq.top().S;
pq.pop();
if(sum < val) {
ok = false;
break;
}
sum += val;
was[u] = true;
for(int j : g[u]) {
if(!was[j]) {
pq.push({a[j],j});
}
}
}
cout << ok;
}
return 0;
}
# | 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... |