Submission #532523

#TimeUsernameProblemLanguageResultExecution timeMemory
532523syl123456Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
0 / 100
773 ms74944 KiB
#include <bits/stdc++.h> #define all(i) (i).begin(), (i).end() using namespace std; void Debug(bool _split) {} template<typename T1, typename ...T2> void Debug(bool _split, T1 i, T2 ...j) { if (_split) cerr << ", "; cerr << i; Debug(true, j...); } #define debug(args...) cerr << "Line(" << __LINE__ << ") : [" << #args << "] is [", Debug(false, args), cerr << "]" << endl template<typename T1, typename T2> ostream& operator << (ostream& i, pair<T1, T2> j) { return i << '(' << j.first << ", " << j.second << ')'; } typedef long long ll; typedef pair<int, int> pi; const int inf = 0x3f3f3f3f, lg = 20; const ll mod = 1e9 + 7, INF = 0x3f3f3f3f3f3f3f3f; signed main() { ios::sync_with_stdio(0), cin.tie(0); int n, m; cin >> n >> m; int a[n]; for (int &i : a) cin >> i; vector<int> qry[n]; int l[m], k[m], ans[m]; for (int i = 0, x; i < m; ++i) cin >> l[i] >> x >> k[i], --l[i], qry[--x].push_back(i); vector<int> stk; for (int i = 0; i < n; ++i) { while (!stk.empty() && a[stk.back()] <= a[i]) stk.pop_back(); stk.push_back(i); for (int j : qry[i]) { int x = lower_bound(all(stk), l[j]) - stk.begin(); if (x >= stk.size() - 1 || a[stk[x]] + a[stk[x + 1]] <= k[j]) ans[j] = 1; else ans[j] = 0; } } for (int i : ans) cout << i << '\n'; }

Compilation message (stderr)

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |             if (x >= stk.size() - 1 || a[stk[x]] + a[stk[x + 1]] <= k[j])
      |                 ~~^~~~~~~~~~~~~~~~~
#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...