Submission #881664

# Submission time Handle Problem Language Result Execution time Memory
881664 2023-12-01T17:41:01 Z Juan Stranded Far From Home (BOI22_island) C++17
0 / 100
146 ms 14600 KB
#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];
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;
	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;	
	}

	sort(v+1,v+n+1);
	reverse(v+1, v+n+1);
	set<int> st;
	st.insert(0), st.insert(n+1);
	ans[v[1].ss]=true;
	st.insert(v[1].ff);
	for(int i=2; i<=n; i++){
		auto[val,id] = v[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);
		// cout << l << " " << r << endl;
	}

	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 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 146 ms 14544 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 113 ms 14600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -