답안 #497542

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
497542 2021-12-23T08:25:07 Z Nuraly_Serikbay Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
0 / 100
917 ms 33504 KB
#include <bits/stdc++.h>
  
#define endl "\n"
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz size()
#define rep(i,k,n) for(int i = k ; i <= n ; ++i)
#define per(i,k,n) for(int i = k ; i >= n ; --i)
#define Zymraq() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define fr(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define toqta return 0
#define PERMUTE next_permutation
#define no cout<<"No"<<endl;
#define yes cout<<"Yes"<<endl;
#define a() a + 1, a + n + 1  
 
  
using namespace std;
   
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse,-fgcse-lm")
#pragma GCC optimize("-ftree-pre,-ftree-vrp")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")

typedef long long ll;
typedef unsigned long long ull;
typedef string S;
typedef double ld;
typedef long double lld;
   
const int N = 1e6 + 17;
const int modd = 1e9 + 7;
const ll INF = 1e18 - 19;
const int P = 37;
const ll NN = 1e7 + 17;
const ld eps = 1e-19;
const double pi = 3.141592653589793238462643383279 ;
   
 
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){
    return (a.second < b.second);
}
 
void pre (ll a) {
    cout << fixed << setprecision(a);
    return;
}
 
ll n, q;
ll a[N], b[N];
ll t[N], tt[N];

void build (ll l, ll r, ll v) {
	if (l == r) {
		t[v] = a[l], tt[v] = 0;
		return;
	}
	ll mid = (l + r) >> 1;
	build (l, mid, v * 2);
	build (mid + 1, r, v * 2 + 1);
	t[v] = max (t[v * 2], t[v * 2 + 1]);
	if (t[v * 2] > t[v * 2 + 1]) {
		tt[v] = max (tt[v], t[v * 2] + t[v * 2 + 1]);
	}
	return;
}

ll get (ll l, ll r, ll tl, ll tr, ll v) {
	if (l <= tl && tr <= r) {
		return tt[v];
	}
	if (tr < l || r < tl) {
		return 0;
	}
	ll mid = (tl + tr) >> 1;
	return max (get (l, r, tl, mid, v * 2), get (l, r, mid + 1, tr, v * 2 + 1));
}

inline void Solution () {
	cin >> n >> q;
	for (int i = 1; i <= n; ++ i) {
		cin >> a[i];
	}
	build (1, n, 1);
	while (q --) {
		ll l, r, k, mx = 0;
		cin >> l >> r >> k;
		if (get (l, r, 1, n, 1) > k) cout << 0 << '\n';
		else cout << 1 << '\n';
	}
	return;
}    
 
 
int main () {
	Zymraq();
	Solution ();
	exit (0);
}

Compilation message

sortbooks.cpp: In function 'void Solution()':
sortbooks.cpp:95:15: warning: unused variable 'mx' [-Wunused-variable]
   95 |   ll l, r, k, mx = 0;
      |               ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 917 ms 33504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 77 ms 5376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -