#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
void solve(){
int n, m; cin >> n >> m;
vector<int> s(n);
for(auto &u : s) cin >> u;
vector<vector<int>> g(n);
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);
}
auto check = [&](int i)->int{
priority_queue<pair<int,int>> q;
ll cur = s[i];
vector<int> used(n);
used[i] = 1;
for(auto u : g[i]){
q.push({-s[u], u});
}
//cout << i << ": " << cur << endl;
while(!q.empty()){
int t = q.top().second;
q.pop();
if(s[t] <= cur){
cur += s[t];
}else{
return 0;
}
for(auto u : g[t]){
if(used[u]) continue;
used[u] = 1;
q.push({-s[u], u});
}
}
return 1;
};
for(int i = 0; i < n; i ++){
cout << check(i);
}
}
signed main(){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int testcases = 1;
//cin >> testcases;
while(testcases --){
solve();
if(testcases) cout << '\n';
#ifdef LOCAL
else cout << '\n';
cout << "___________________" << endl;
#endif
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
161 ms |
468 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Execution timed out |
1064 ms |
16428 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1087 ms |
14300 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1073 ms |
15532 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
161 ms |
468 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |