제출 #1007260

#제출 시각아이디문제언어결과실행 시간메모리
1007260Rolo678Fish 3 (JOI24_fish3)C++14
0 / 100
66 ms8940 KiB
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0)->sync_with_stdio(false); long long n,d; int q; cin >> n >> d; vector<int>c(n+5); vector<int>ans(n+1,0); for (int i = 1; i <= n; i++) { cin >> c[i]; ans[i] = ans[i-1] + (c[i] == 0 && c[i-1]==1); } cin >> q; while(q--) { int l,r; cin >> l >> r; if(ans[r]-ans[l-1]==0) { cout << 0 << '\n'; } else if(d==1) { cout << ans[r]-ans[l-1] << '\n'; } else { cout << -1 << '\n'; } } }
#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...