Submission #1058524

# Submission time Handle Problem Language Result Execution time Memory
1058524 2024-08-14T10:32:27 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
0 / 100
487 ms 82776 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pf push_front
#define fi first
#define se second
const ll mod = 1e9+7, mxn = 1e6+7;
ll bit[mxn], n, q, w[mxn], lis[mxn];
bool ans[mxn];
vector<vector<pair<pair<ll,ll>,ll>>> qx(mxn);
void upd(ll u, ll v) {if (!u) {return;} while (u < mxn) {bit[u] = max(bit[u],v); u += (u&(-u));}}
ll get(ll u) {ll sum = 0; while (u) {sum = max(sum,bit[u]); u -= (u&(-u));} return sum;}
signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // freopen("test.inp","r",stdin); freopen("test.out","w",stdout); freopen("test.err","w",stderr);
    cin >> n >> q;
    for (ll i = 1; i <= n; i++)
    {
        cin >> w[i]; lis[i] = i-1;
        while (lis[i] && w[i] >= w[lis[i]]) lis[i] = lis[lis[i]];
    }
    for (ll i = 1; i <= q; i++)
    {
        ll l, r, c; cin >> l >> r >> c;
        qx[r].pb({{l,i},c});
    }
    for (ll i = 1; i <= n; i++)
    {
        upd(lis[i],w[lis[i]]+w[i]);
        for (pair<pair<ll,ll>,ll> j : qx[i]) ans[j.fi.se] = (get(j.fi.fi) <= j.se);
    }
    for (ll i = 1; i <= q; i++) cout << ans[i] << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 30044 KB Output is correct
2 Correct 4 ms 30044 KB Output is correct
3 Incorrect 4 ms 30044 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 30044 KB Output is correct
2 Correct 4 ms 30044 KB Output is correct
3 Incorrect 4 ms 30044 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 487 ms 82776 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 33444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 30044 KB Output is correct
2 Correct 4 ms 30044 KB Output is correct
3 Incorrect 4 ms 30044 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 30044 KB Output is correct
2 Correct 4 ms 30044 KB Output is correct
3 Incorrect 4 ms 30044 KB Output isn't correct
4 Halted 0 ms 0 KB -