답안 #497900

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
497900 2021-12-24T04:34:42 Z Ierus Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
1539 ms 129844 KB
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
using namespace std;
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
#define F first
#define S second
#define sz(x) (int)x.size()
#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
const int E = 1e6+777;
const long long inf = 1e18+777;
const int N = 1e5+777;
const int MOD = 1e9+7;
const bool I = 1;
int n, que, a[E] = {inf}, t[E<<2], ans[E];
void update(int pos, int val, int v, int tl, int tr){
	if(tl == tr){
		t[v] = max(pos, t[v]);
		return;
	}
	int tm = (tl + tr) / 2;
	if(pos <= tm) update(pos, val, v<<1, tl, tm);
	else update(pos, val, v<<1|1, tm+1, tr);
	t[v] = max(t[v<<1], t[v<<1|1]);
}
int get(int l, int r, int v, int tl, int tr){
	if(l <= tl && tr <= r) return t[v];
	if(tl > r || tr < l) return 0;
	int tm = (tl + tr) / 2;
	return max(get(l, r, v<<1, tl, tm), get(l, r, v<<1|1, tm+1, tr));
}
struct D{
	int l, x, i;
};
vector<D> g[N];
signed main(){
	cin >> n >> que;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
	}
	for(int l, r, x, i = 1; i <= que; ++i){
		cin >> l >> r >> x;
		g[r].pb({l, x, i});
	}
	deque<pair<int,int>> st = {{inf, 0}};
	for(int i = 1; i <= n; ++i){
		while(!st.empty() && st.back().F <= a[i]) st.pop_back();
		if(!st.empty()) update(st.back().S, st.back().F + a[i], 1, 0, n);
		for(auto to : g[i]){
			int cur = get(to.l, i, 1, 0, n);
			ans[to.i] = (cur <= to.x);
		}
		st.push_back({a[i], i});
	}
	for(int i = 1; i <= que; ++i){
		cout << ans[i] << '\n';
	}
}











# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1539 ms 129844 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 144 ms 9700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -