이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |