# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
651223 | 2022-10-18T03:15:11 Z | alexccc | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 551 ms | 6368 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(ind != sub.size() && r<=sub[ind + 1].second){ putchar('1'); putchar('\n'); }else{ putchar('0'); putchar('\n'); } } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 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 | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 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 | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 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 | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 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 | 340 KB | Output is correct |
13 | Correct | 2 ms | 340 KB | Output is correct |
14 | Correct | 3 ms | 340 KB | Output is correct |
15 | Correct | 3 ms | 340 KB | Output is correct |
16 | Correct | 13 ms | 368 KB | Output is correct |
17 | Correct | 13 ms | 352 KB | Output is correct |
18 | Correct | 12 ms | 368 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 551 ms | 6368 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 44 ms | 984 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 | 0 ms | 212 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 | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 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 | 340 KB | Output is correct |
13 | Correct | 2 ms | 340 KB | Output is correct |
14 | Correct | 3 ms | 340 KB | Output is correct |
15 | Correct | 3 ms | 340 KB | Output is correct |
16 | Correct | 13 ms | 368 KB | Output is correct |
17 | Correct | 13 ms | 352 KB | Output is correct |
18 | Correct | 12 ms | 368 KB | Output is correct |
19 | Incorrect | 120 ms | 1596 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 | 0 ms | 212 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 | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 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 | 340 KB | Output is correct |
13 | Correct | 2 ms | 340 KB | Output is correct |
14 | Correct | 3 ms | 340 KB | Output is correct |
15 | Correct | 3 ms | 340 KB | Output is correct |
16 | Correct | 13 ms | 368 KB | Output is correct |
17 | Correct | 13 ms | 352 KB | Output is correct |
18 | Correct | 12 ms | 368 KB | Output is correct |
19 | Incorrect | 551 ms | 6368 KB | Output isn't correct |
20 | Halted | 0 ms | 0 KB | - |