#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');
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2 ms |
4944 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3 ms |
4944 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2 ms |
4944 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2 ms |
4944 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |