답안 #497902

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
497902 2021-12-24T04:35:48 Z Ierus Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
34 / 100
1474 ms 129736 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(val, 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 1 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 5 ms 2764 KB Output is correct
12 Correct 6 ms 2892 KB Output is correct
13 Correct 7 ms 2892 KB Output is correct
14 Correct 9 ms 3020 KB Output is correct
15 Correct 9 ms 3020 KB Output is correct
16 Correct 7 ms 3000 KB Output is correct
17 Correct 9 ms 2892 KB Output is correct
18 Correct 6 ms 2892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1474 ms 129736 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 9668 KB Output is correct
2 Correct 129 ms 9932 KB Output is correct
3 Correct 149 ms 7736 KB Output is correct
4 Correct 133 ms 7740 KB Output is correct
5 Correct 134 ms 7620 KB Output is correct
6 Correct 110 ms 7808 KB Output is correct
7 Correct 119 ms 7760 KB Output is correct
8 Correct 115 ms 7460 KB Output is correct
9 Correct 89 ms 6552 KB Output is correct
10 Correct 120 ms 7432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 5 ms 2764 KB Output is correct
12 Correct 6 ms 2892 KB Output is correct
13 Correct 7 ms 2892 KB Output is correct
14 Correct 9 ms 3020 KB Output is correct
15 Correct 9 ms 3020 KB Output is correct
16 Correct 7 ms 3000 KB Output is correct
17 Correct 9 ms 2892 KB Output is correct
18 Correct 6 ms 2892 KB Output is correct
19 Runtime error 313 ms 37088 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 5 ms 2764 KB Output is correct
12 Correct 6 ms 2892 KB Output is correct
13 Correct 7 ms 2892 KB Output is correct
14 Correct 9 ms 3020 KB Output is correct
15 Correct 9 ms 3020 KB Output is correct
16 Correct 7 ms 3000 KB Output is correct
17 Correct 9 ms 2892 KB Output is correct
18 Correct 6 ms 2892 KB Output is correct
19 Runtime error 1474 ms 129736 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -