#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a; i<b; i++)
typedef vector<int>vi;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
void IO() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
/////////////////////////ONLY CLEAN CODES ALLOWED/////////////////////////
int main(){
IO();
int N,M;
cin>>N>>M;
vi a(N);
FOR(i,0,N) cin>>a[i];
vi adj[N];
FOR(i,0,M){
int u,v; cin>>u>>v;
u--; v--;
adj[u].pb(v); adj[v].pb(u);
}
vi ans(N,1);
FOR(st,0,N){
vi vis(N,0); vis[st]=1;
int X=a[st];
int nb=1;
while(1){
int flag=0;
FOR(i,0,N) if(vis[i]){
for(int j: adj[i]) if(!vis[j] && X>=a[j]){
X+=a[j];
vis[j]=1;
nb++;
flag=1;
}
if(flag) break;
}
if(nb==N) break;
if(!flag) break;
}
FOR(i,0,N) ans[st]&=vis[i];
}
FOR(i,0,N) cout << ans[i];
cout << endl;
}
# |
Verdict |
Execution time |
Memory |
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 |
9 ms |
340 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Execution timed out |
1040 ms |
15072 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1087 ms |
16716 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1048 ms |
15340 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
9 ms |
340 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |