Submission #1094969

#TimeUsernameProblemLanguageResultExecution timeMemory
1094969eysbutnoHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
0 / 100
3083 ms20676 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = array<int, 2>; #define all(x) begin(x), end(x) #define sz(x) (int) (x).size() int main() { cin.tie(0) -> sync_with_stdio(0); int n, q; cin >> n >> q; vector<int> w(n); for (int &i : w) { cin >> i; } for (int t = 0; t < q; t++) { int l, r, k; cin >> l >> r >> k; --l, --r; vector<int> sorted; for (int i = l; i <= r; i++) { sorted.push_back(w[i]); } sort(all(sorted)); int big = -1; int mn = INT_MAX; for (int i = r; i >= l; i--) { if (sorted[i - l] != w[i]) { big = max(big, w[i]); mn = min(mn, w[i]); } } if (big == -1) { cout << 1; } else if (mn + big <= k) { cout << 1; } else { cout << 0; } cout << "\n"; } } // this is just for subtasks lmao to see if my sol is right
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...