Submission #1071993

# Submission time Handle Problem Language Result Execution time Memory
1071993 2024-08-23T13:07:44 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
17 / 100
3000 ms 159884 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define nn "\n";
const int N = 2e6 + 8  , inf = 1e9+7 ;
int  n , m , q ;
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin>> n >> q;
    int w[n+1] , l[q+1] , r[q+1] , k[q+1] , p[n+1];
    int mx1 = max(n , q );
    int mx2 =0 ;
    p[1] =0 ;
    for(int i= 1 ; i <= n; i++){
        cin>> w[i];
        if(i > 1 ) {
            p[i] = p[i - 1];
            if(w[i]>= w[i-1])p[i]++;
        }
        if(w[i]< mx2) {
            mx2 = max(mx2 , w[i]);
            p[i]++;
        }
    }
    for(int i =1 ; i <= q; i++){
        cin>> l[i]>> r[i]>> k[i];
    }
    if(mx1 <= 5000){
        for(int i =1 ; i <=  q; i++){
            int mx =w[l[i]] , cnt =0  ;
            for(int j =l[i]+1 ; j <= r[i] ; j++){
                if(w[j]< mx ){
                    cnt = max(cnt , w[j]+mx);
                }
                else mx = w[j];
            }
            if(cnt <= k[i] ){
                cout << 1 << nn
            }
            else cout << 0 << nn
        }
    }
    else{
        for(int i =1 ; i <= q ;q ++){
            if(p[r[i]] - p[l[i]]==r[i]-l[i])cout << 1 << nn
            else cout << 0 << nn
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 5 ms 604 KB Output is correct
14 Correct 10 ms 604 KB Output is correct
15 Correct 8 ms 648 KB Output is correct
16 Correct 11 ms 604 KB Output is correct
17 Correct 7 ms 600 KB Output is correct
18 Correct 10 ms 648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3052 ms 159884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3036 ms 131036 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 5 ms 604 KB Output is correct
14 Correct 10 ms 604 KB Output is correct
15 Correct 8 ms 648 KB Output is correct
16 Correct 11 ms 604 KB Output is correct
17 Correct 7 ms 600 KB Output is correct
18 Correct 10 ms 648 KB Output is correct
19 Execution timed out 3045 ms 139648 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 5 ms 604 KB Output is correct
14 Correct 10 ms 604 KB Output is correct
15 Correct 8 ms 648 KB Output is correct
16 Correct 11 ms 604 KB Output is correct
17 Correct 7 ms 600 KB Output is correct
18 Correct 10 ms 648 KB Output is correct
19 Execution timed out 3052 ms 159884 KB Time limit exceeded
20 Halted 0 ms 0 KB -