#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long int
#define oo 4e18
#define pii pair<int, int>
const int MAX = 2e5 + 5;
ll Presum[MAX];
int arr[MAX];
int ans[MAX];
int main(){
int n, m; cin >> n >> m;
vector<pii> v;
for (int i = 1; i <= n; i++)
{
cin >> arr[i];
Presum[i] = Presum[i - 1] + arr[i];
v.push_back({arr[i], i});
}
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
for (int i = 0; i < m; i++)
{
int a, b; cin >> a >> b;
}
set<int> s;
s.insert(0);
s.insert(n + 1);
s.insert(v[0].second);
for(pii &a: v){
auto itr = s.upper_bound(a.second);
int l = (*(prev(itr)));
int r = (*itr);
s.insert(a.second);
ll sum = Presum[r - 1] - Presum[l];
if((sum >= arr[l] && ans[l]) || (sum >= arr[r] && ans[r])){
ans[a.second] = 1;
continue;
}
}
for (int i = 1; i <= n; i++)
{
cout << ans[i];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |