Submission #858931

#TimeUsernameProblemLanguageResultExecution timeMemory
858931iulia_morariuSum Zero (RMI20_sumzero)C++17
0 / 100
799 ms620 KiB
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(0);ios::sync_with_stdio(0); //1. int n, q; //2. cin >> n; int v[n], sp[n + 1]; sp[0] = 0; //3. for(int i = 0; i < n; i++){ cin >> v[i]; sp[i + 1] = sp[i] + v[i]; } cin >> q; for(int iii = 0; iii < q; iii++){ int l, r; cin >> l >> r; map<int, int> mp; int cnt = 0; int lp = l - 1; mp[ sp[lp] ]++; for(int i = l; i <= r; i++){ //cout << "i = " << i << " cnt = "; if(mp.find( sp[i] ) == mp.end()){ mp[ sp[i] ] = i; }else{ if( mp[ sp[i] ] >= lp ){ //cout << "( facem cu " << mp[ sp[i] ] << " ) "; lp = i; cnt++; } mp[ sp[i] ] = i; } //cout << cnt << endl; } cout << cnt << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...