Submission #162945

#TimeUsernameProblemLanguageResultExecution timeMemory
162945dandrozavrHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
17 / 100
3032 ms5156 KiB
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double
#define endl '\n'
#define TIME 1.0*clock()/CLOCKS_PER_SEC

using namespace std;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int N = 3e5 + 7;
const int M = 1e9 + 7;
const int FFTM = 998244353;

int n, m, x[N], l, r, k, y;
int dp[404][404][404];

inline int s(int i, int j){
    return x[j] - x[i];
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef Estb_probitie
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> m;
    int a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < m; ++i)
    {
        int l, r, k;
        cin >> l >> r >> k;
        --l, --r;
        int mx = 0;
        int ans = 0;
        for (int i = l; i <= r; ++i)
        {
            if (mx > a[i])

                ans = max(ans, mx + a[i]); else
                mx = a[i];
        }
//        cout<<ans<<" "<<k<<endl;
        if (ans <= k)
            cout<<1<<'\n'; else cout << 0<<'\n';
    }
}

Compilation message (stderr)

sortbooks.cpp:26:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
#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...