Submission #1071660

# Submission time Handle Problem Language Result Execution time Memory
1071660 2024-08-23T09:46:03 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
348 ms 58324 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define nn "\n";
const int N = 2e5 + 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[0] =0 ;
    for(int i= 1 ; i <= n; i++){
        cin>> w[i];
        p[i] = p[i-1];
        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 i =l[i]+1 ; i <= r[i] ; i++){
                if(w[i]< mx ){
                    cnt = max(cnt , w[i]+mx);
                }
                else mx = w[i];
            }
            if(cnt <= k[i] ){
                cout << 1 << nn
            }
            else cout << 0 << nn
        }
    }
    else{
        for(int i =1 ; i <= q ; i++){
            if(p[r[i]] - p[l[i-1]]==0)cout << 1<< nn
            else cout << 0 << nn 
        }
    }
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:28:27: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 |             for(int i =l[i]+1 ; i <= r[i] ; i++){
      |                        ~~~^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 348 ms 58324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 5712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -