Submission #497425

# Submission time Handle Problem Language Result Execution time Memory
497425 2021-12-23T05:12:15 Z Ziel Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
8 / 100
3000 ms 29068 KB
/**
 * LES GREATEABLES BRO TEAM
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
#define sz(x) (int)x.size()
const bool FLAG = false;
void setIO(const string &f = "");

const int N = 1e6 + 234;
int a[N], n, q;

void solve() {
    cin >> n >> q;
    for (int i = 1; i <= n; i++)
    	cin >> a[i];
    while (q--) {
    	int l, r, k;
    	cin >> l >> r >> k;
    	ordered_set<int> s;
    	int mx = 0;
    	for (int i = r; i >= l; i--) {
    		if (sz(s)) {
    			int it = s.order_of_key(a[i]);
    			if (it > 0)
    				mx = max(mx, a[i] + (*s.find_by_order(it - 1)));
    		}
    		s.insert(a[i]);
    	}
    	cout << bool(mx <= k) << '\n';
    }
}

signed main() {
    setIO();
    
    int tt = 1;
    if (FLAG) {
    	cin >> tt;
    }
    while (tt--) {
    	solve();
    }
    
    return 0;
}

void setIO(const string &f) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if (fopen((f + ".in").c_str(), "r")) {
        freopen((f + ".in").c_str(), "r", stdin);
        freopen((f + ".out").c_str(), "w", stdout);
    }
}

Compilation message

sortbooks.cpp: In function 'void setIO(const string&)':
sortbooks.cpp:60:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |         freopen((f + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen((f + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 2 ms 308 KB Output is correct
6 Correct 23 ms 340 KB Output is correct
7 Correct 19 ms 360 KB Output is correct
8 Correct 28 ms 352 KB Output is correct
9 Correct 11 ms 320 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 2 ms 308 KB Output is correct
6 Correct 23 ms 340 KB Output is correct
7 Correct 19 ms 360 KB Output is correct
8 Correct 28 ms 352 KB Output is correct
9 Correct 11 ms 320 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 377 ms 452 KB Output is correct
12 Correct 1322 ms 652 KB Output is correct
13 Correct 1521 ms 656 KB Output is correct
14 Correct 2595 ms 700 KB Output is correct
15 Correct 2454 ms 704 KB Output is correct
16 Execution timed out 3052 ms 792 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3080 ms 29068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3076 ms 716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 2 ms 308 KB Output is correct
6 Correct 23 ms 340 KB Output is correct
7 Correct 19 ms 360 KB Output is correct
8 Correct 28 ms 352 KB Output is correct
9 Correct 11 ms 320 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 377 ms 452 KB Output is correct
12 Correct 1322 ms 652 KB Output is correct
13 Correct 1521 ms 656 KB Output is correct
14 Correct 2595 ms 700 KB Output is correct
15 Correct 2454 ms 704 KB Output is correct
16 Execution timed out 3052 ms 792 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 2 ms 308 KB Output is correct
6 Correct 23 ms 340 KB Output is correct
7 Correct 19 ms 360 KB Output is correct
8 Correct 28 ms 352 KB Output is correct
9 Correct 11 ms 320 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 377 ms 452 KB Output is correct
12 Correct 1322 ms 652 KB Output is correct
13 Correct 1521 ms 656 KB Output is correct
14 Correct 2595 ms 700 KB Output is correct
15 Correct 2454 ms 704 KB Output is correct
16 Execution timed out 3052 ms 792 KB Time limit exceeded
17 Halted 0 ms 0 KB -