This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define ALL(v) (v).begin(), (v).end()
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
#define REP(i, v) for( __typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define F0R(i, n) for(int i = 0, _n = (n); i < _n; ++ i)
#define F0RD(i, n) for(int i = (n); i > 0; -- i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i < _b; ++ i)
#define FORD(i, b, a) for(int i = (b), _a = (a); i > _a; -- i)
#define FORE(i, a, b) for(int i = (a), _b = (b); i <= _b; ++ i)
#define FORDE(i, b, a) for(int i = (b), _a = (a); i >= _a; -- i)
#define __builtin_popcount __builtin_popcountll
#define mxN 300010
#define LOG 19
const string NAME = "BAITAP";
int N, Q;
long long D;
vector<long long> A(mxN);
void init(void){
cin >> N >> D;
FORE(i, 1, N) cin >> A[i];
}
void process(void){
cin >> Q;
FORE(i, 1, Q){
int l, r;
cin >> l >> r;
bool chk = false;
bool ans = true;
FORE(j, l, r){
if(A[j] >= 1) chk = true;
else if(A[j] == 0 && chk == true){
ans = false;
}
}
cout << (ans == true ? 0 : -1) << '\n';
}
}
int main(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef LOCAL
freopen((NAME + ".INP").c_str(), "r", stdin);
freopen((NAME + ".OUT").c_str(), "w", stdout);
#endif // LOCAL
init();
process();
cerr << "\nTime elapsed AC: " << TIME << "s.\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |