#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> G[200001];
ll cad[200001];
ll maxi=0;
ll cmc(ll node)
{
priority_queue<pair<ll,ll>> q;
map<ll,ll> mapa;
ll ac=cad[node];
for(auto i:G[node]) q.push({-cad[i],i});
while(!q.empty()&&ac<maxi&&ac>=-q.top().first)
{
ll temp=q.top().second;q.pop();
ac+=cad[temp];
for(auto i:G[temp])
{
if(mapa[i]==0)
{
mapa[i]=1;
q.push({-cad[i],i});
}
}
}
return (ac>=maxi);
}
int main()
{
ll n,m;
cin>>n>>m;
vector<pair<ll,ll>> temp;
for(int i=1; i<=n; i++)
{
cin>>cad[i];
temp.push_back({cad[i],i});
}
sort(temp.begin(),temp.end());
maxi=temp.back().first;
for(int i=0; i<m; i++)
{
ll a,b;
cin>>a>>b;
G[a].push_back(b);
G[b].push_back(a);
}
vector<ll> sol(n,0);
for(auto i:temp)
{
sol[i.second-1]=cmc(i.second);
}
for(auto i:sol)
cout<<i;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
2 ms |
4956 KB |
Output is correct |
4 |
Incorrect |
4 ms |
5212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Incorrect |
305 ms |
23228 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Incorrect |
184 ms |
17592 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Incorrect |
213 ms |
18592 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
2 ms |
4956 KB |
Output is correct |
4 |
Incorrect |
4 ms |
5212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |