#include<bits/stdc++.h>
using namespace std;
// #pragma GCC optimize (03)
#define int long long
#define ll long long
#define ld long double
#define tii tuple<int,int,int>
#define tii4 tuple<int,int,int,int>
#define pii pair<int,int>
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
const int maxn=2e5+5, M=1e6, INF=0x3f3f3f3f, MOD=998244353;
pii v[maxn], ordered[maxn];
int pref[maxn], ans[maxn];
int solve(){
int n,m; cin >> n >> m;
for(int i=1; i<=n; i++){
cin >> v[i].ff, v[i].ss=i;
ordered[i]=v[i];
}
for(int i=1; i<=n+1; i++) pref[i]=pref[i-1]+v[i].ff;
for(int i=0; i<m; i++){
int a,b; cin >> a >> b;
}
set<int> st;
st.insert(0), st.insert(n+1);
sort(ordered+1, ordered+n+1, greater<pii>());
ans[ordered[1].ss]=true;
st.insert(ordered[1].ss);
for(int i=2; i<=n; i++){
auto[val,id] = ordered[i];
// query
int r = *(st.lower_bound(id));
int l = *(prev(st.lower_bound(id)));
int val_range = pref[r-1]-pref[l];
// upd
if(val_range >= v[l].ff && ans[l]) ans[id]=true;
if(val_range >= v[r].ff && ans[r]) ans[id]=true;
st.insert(id);
}
for(int i=1; i<=n; i++) cout << ans[i];
cout << '\n';
return 0;
}
int32_t main(){
ios::sync_with_stdio(false); cin.tie(0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int t=1;
// cin >> t;
while(t--){
if(solve()) break;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Incorrect |
2 ms |
4440 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Incorrect |
103 ms |
19204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
164 ms |
19152 KB |
Output is correct |
3 |
Correct |
152 ms |
23740 KB |
Output is correct |
4 |
Correct |
127 ms |
23888 KB |
Output is correct |
5 |
Correct |
109 ms |
20556 KB |
Output is correct |
6 |
Correct |
161 ms |
23636 KB |
Output is correct |
7 |
Correct |
129 ms |
23888 KB |
Output is correct |
8 |
Correct |
131 ms |
23892 KB |
Output is correct |
9 |
Correct |
108 ms |
22864 KB |
Output is correct |
10 |
Correct |
108 ms |
23248 KB |
Output is correct |
11 |
Correct |
108 ms |
20820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Incorrect |
114 ms |
19284 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Incorrect |
2 ms |
4440 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |