제출 #341848

#제출 시각아이디문제언어결과실행 시간메모리
341848boykutHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
8 / 100
3096 ms10064 KiB
#include <bits/stdc++.h> using namespace std; #define work_with_io ios::sync_with_stdio(0);cin.tie(0); //#define int long long void solve() { int n, m, mna = -1; cin >> n >> m; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (mna == -1 || a[i] < mna) mna = a[i]; } int dp[n]; dp[0] = 1; for (int i = 1; i < n; i++) { if (a[i] >= a[i - 1]) dp[i] = dp[i - 1] + 1; else dp[i] = 1; } for (int tmp=0;tmp<m;tmp++) { int l, r, k; cin >> l >> r >> k; l--;r--; if (k < mna) { r-l+1 <= dp[r]?cout << "1\n":cout << "0\n"; } else { int ans = 1; for (int left = l; left <= r; left++) { for (int right = left + 1; right <= r; right++) { if (a[left] > a[right] && a[left] + a[right] > k) ans = 0; } } cout << ans << '\n'; } } return; } signed main() { //std::work_with_io; int q = 1; //cin >> q; while (q--) { solve(); } return 0; }
#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...