Submission #681428

# Submission time Handle Problem Language Result Execution time Memory
681428 2023-01-13T05:22:32 Z DanTatar Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
30 / 100
1532 ms 43036 KB
#include <bits/stdc++.h>
#define pb push_back
#define sz(v) v.size()
#define in insert
#define ld double
#define all(v) v.begin(),v.end()
#define ent endl
#define S second
#define F first
#define pii pair <int, int>
//#define int long long

/*#pragma optimize ("g",on)
#pragma GCC optimize ("inline")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
#pragma comment(linker, "/stack:200000000")*/

using namespace std;

//const int INF = 1e18 + 123;
const int N = 1e6 + 123;
const int mod = 998244353;
const double PI = 3.1415926536;

const double eps = 1e-20;

int dx[4] = {0, 1, 0, -1};
int dy[4] = {-1, 0, 1, 0};

void speed(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int n,m;
int a[N];
int pref[N];

void solve(){
    cin >> n >> m;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
    }

    if(n <= 5000 && m <= 5000){
        while(m --){
            int l,r,k;
            cin >> l >> r >> k;
            int b[r-l+10];
            for(int i = 1; i <= r-l+1; ++i){
                b[i] = a[i+l-1];
            }

            multiset <int> st;
            int ok = 1;
            for(int i = 1; i <= r-l+1; ++i){
                if(st.empty()){
                    st.insert(b[i]);
                    continue;
                }

                if(*st.rbegin() > b[i] && *st.rbegin() + b[i] > k){
                    ok = 0;
                    break;
                }

                st.insert(b[i]);
            }

            cout << ok << ent;
        }
    } else {
        for(int i = 1; i <= n; i++){
            if(a[i] < a[i - 1]) {
                pref[i] = i;
            } else {
                pref[i] = pref[i - 1];
            }
        }

        while(m--){
            int l, r, k;
            cin >> l >> r >> k;
            cout << (pref[r] <= l) << ent;
        }
    }
}

signed main() {
	speed();
    int tt = 1;
    //cin >> tt;
    while(tt --){
        solve();
        cout << ent;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 8 ms 340 KB Output is correct
9 Correct 5 ms 340 KB Output is correct
10 Correct 7 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 8 ms 340 KB Output is correct
9 Correct 5 ms 340 KB Output is correct
10 Correct 7 ms 340 KB Output is correct
11 Correct 8 ms 340 KB Output is correct
12 Correct 9 ms 588 KB Output is correct
13 Correct 10 ms 468 KB Output is correct
14 Correct 17 ms 712 KB Output is correct
15 Correct 14 ms 472 KB Output is correct
16 Correct 965 ms 692 KB Output is correct
17 Correct 934 ms 744 KB Output is correct
18 Correct 838 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1497 ms 10604 KB Output is correct
2 Correct 1500 ms 43012 KB Output is correct
3 Correct 1519 ms 42768 KB Output is correct
4 Correct 1532 ms 43036 KB Output is correct
5 Correct 1483 ms 43004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 151 ms 2744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 8 ms 340 KB Output is correct
9 Correct 5 ms 340 KB Output is correct
10 Correct 7 ms 340 KB Output is correct
11 Correct 8 ms 340 KB Output is correct
12 Correct 9 ms 588 KB Output is correct
13 Correct 10 ms 468 KB Output is correct
14 Correct 17 ms 712 KB Output is correct
15 Correct 14 ms 472 KB Output is correct
16 Correct 965 ms 692 KB Output is correct
17 Correct 934 ms 744 KB Output is correct
18 Correct 838 ms 604 KB Output is correct
19 Incorrect 307 ms 8788 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 8 ms 340 KB Output is correct
9 Correct 5 ms 340 KB Output is correct
10 Correct 7 ms 340 KB Output is correct
11 Correct 8 ms 340 KB Output is correct
12 Correct 9 ms 588 KB Output is correct
13 Correct 10 ms 468 KB Output is correct
14 Correct 17 ms 712 KB Output is correct
15 Correct 14 ms 472 KB Output is correct
16 Correct 965 ms 692 KB Output is correct
17 Correct 934 ms 744 KB Output is correct
18 Correct 838 ms 604 KB Output is correct
19 Correct 1497 ms 10604 KB Output is correct
20 Correct 1500 ms 43012 KB Output is correct
21 Correct 1519 ms 42768 KB Output is correct
22 Correct 1532 ms 43036 KB Output is correct
23 Correct 1483 ms 43004 KB Output is correct
24 Incorrect 151 ms 2744 KB Output isn't correct
25 Halted 0 ms 0 KB -