제출 #889954

#제출 시각아이디문제언어결과실행 시간메모리
889954vjudge1Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
13 / 100
1014 ms59216 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include<bits/stdc++.h> #define ll long long #define F first #define S second #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define all(x) x.begin(), x.end() #define sz(x) x.size() #define forik(x) ll i = 1; i <= x; i++ // (a mod 1e9) / (b mod 1e9) = a * (b^1e9) using namespace std; ll a, b, c, d, e, f, n, m, k, p[1000001], l, md[8000001]; pair <ll, ll> t[8000001]; pair <ll, ll> qw (pair <ll, ll> a, pair <ll, ll> b){ // cout << a.F << ' ' << a.S << ' ' << b.F << ' ' << b.S << '\n'; if (a.F == -1 && b.F == -1){ return {-1, -1}; } if (b.F == -1){ return a; } if (a.F == -1){ return b; } if (a.S > b.F){ d = max (d, a.S + b.F); } if (a.S > b.S){ d = max (d, a.S + b.S); } return {min (a.F, b.F), max (b.S, a.S)}; } void build (ll tl = 1, ll tr = n, ll v = 1){ if (tl == tr){ t[v] = {p[tl], p[tl]}; return; } ll tm = (tl + tr) / 2; build (tl, tm, v * 2); build (tm + 1, tr, v * 2 + 1); if (t[v * 2].S > t[v * 2 + 1].F){ md[v] = t[v * 2 + 1].F + t[v * 2].S; } t[v] = {min (t[v * 2].F, t[v * 2 + 1].F), max (t[v * 2].S, t[v * 2 + 1].S)}; } pair <ll, ll> get (ll l, ll r, ll tl = 1, ll tr = n, ll v = 1){ if (l <= tl && tr <= r){ d = max (d, md[v]); return t[v]; } if (tl > r || l > tr){ return {-1, -1}; } ll tm = (tl + tr) / 2; return qw (get (l, r, tl, tm, v * 2), get (l, r, tm + 1, tr, v * 2 + 1)); } signed main (){ //freopen (".in", "r", stdin); //freopen (".out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++){ cin >> p[i]; } build (); while (m--){ cin >> a >> b >> c; d = 0; pair <ll, ll> ans = get (a, b); if (d > c){ cout << "0\n"; } else{ cout << "1\n"; } } }

컴파일 시 표준 에러 (stderr) 메시지

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:81:17: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   81 |   pair <ll, ll> ans = get (a, b);
      |                 ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...