Submission #532523

# Submission time Handle Problem Language Result Execution time Memory
532523 2022-03-03T04:42:33 Z syl123456 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
773 ms 74944 KB
#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

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 time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Incorrect 1 ms 316 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Incorrect 1 ms 316 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 773 ms 74944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 8004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Incorrect 1 ms 316 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Incorrect 1 ms 316 KB Output isn't correct
4 Halted 0 ms 0 KB -