Submission #646626

#TimeUsernameProblemLanguageResultExecution timeMemory
646626VanillaSum Zero (RMI20_sumzero)C++17
22 / 100
173 ms596 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int64; const int maxn = 5e3 + 2; int64 a [maxn]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++){ cin >> a[i]; } int q; cin >> q; while (q--) { int l,r, rs = 0; cin >> l >> r; int last = l; for (int i = 1; i <= r; i++){ int64 sum = 0; for (int j = i; j >= last; j--){ sum+=a[j]; if (!sum) { rs++; last = i + 1; } } } cout << rs << "\n"; } // for (auto i: sv){ // cout << i.first << " " << i.second << "\n"; // } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...