Submission #651222

# Submission time Handle Problem Language Result Execution time Memory
651222 2022-10-18T03:13:35 Z alexccc Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
17 / 100
564 ms 6324 KB
#include <bits/stdc++.h> 

#pragma GCC optimize("Ofast")

using namespace std;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    if(n <= 5000 && m <= 5000){
        vector<long long> w(n + 1);
        for(int i = 1; i <= n; i ++) cin >> w[i];
        int l, r, k;
        for(int i = 0; i < m; i ++){
            cin >> l >> r >> k;
            long long mx = w[l];
            int check = 1;
            for(int j = l; j <= r; j ++){
                if(w[j] < mx && mx + w[j] > k){
                    check = 0;
                    break;
                }
                mx = max(mx,w[j]);
            }
            if(check==0)putchar('0');
            else putchar('1');
            putchar('\n');
        }
    }else{
        bool flag = true;
        int pre = 0;
        vector<pair<int,int>> sub;
        int left = 1, last = 0, now;
        for(int i = 1; i <= n; i ++){
            cin >> now;
            if(now < last){
                sub.push_back({left,i-1});//l to i-1 is increasing
                left = i;
            }
            last = now;
        }
        int l,r,k,sz=sub.size();
        for(int i=0;i<m;i++){
            cin>>l>>r>>k;
            int ind=lower_bound(sub.begin(),sub.end(),make_pair(l,r))-sub.begin();
            if(r<=sub[ind].second){
                putchar('1');
                putchar('\n');
            }else{
                putchar('0');
                putchar('\n');
            }
            
        }
    }

    return 0;
    
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:34:14: warning: unused variable 'flag' [-Wunused-variable]
   34 |         bool flag = true;
      |              ^~~~
sortbooks.cpp:35:13: warning: unused variable 'pre' [-Wunused-variable]
   35 |         int pre = 0;
      |             ^~~
sortbooks.cpp:46:19: warning: unused variable 'sz' [-Wunused-variable]
   46 |         int l,r,k,sz=sub.size();
      |                   ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 3 ms 464 KB Output is correct
16 Correct 13 ms 472 KB Output is correct
17 Correct 13 ms 468 KB Output is correct
18 Correct 12 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 564 ms 6324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 3 ms 464 KB Output is correct
16 Correct 13 ms 472 KB Output is correct
17 Correct 13 ms 468 KB Output is correct
18 Correct 12 ms 340 KB Output is correct
19 Incorrect 106 ms 1868 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 3 ms 464 KB Output is correct
16 Correct 13 ms 472 KB Output is correct
17 Correct 13 ms 468 KB Output is correct
18 Correct 12 ms 340 KB Output is correct
19 Incorrect 564 ms 6324 KB Output isn't correct
20 Halted 0 ms 0 KB -