Submission #402288

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
4022882021-05-11 14:33:27nandonathanielSum Zero (RMI20_sumzero)C++14
100 / 100
752 ms15284 KiB
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int MAXN=400005,LOG=4;
int kiri[MAXN],pa[LOG][MAXN],idx[MAXN],MAX;
vector<pii> V;
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int N,L,R;
cin >> N;
memset(kiri,-1,sizeof(kiri));
memset(idx,-1,sizeof(idx));
long long sum=0;
V.push_back({sum,0});
for(int i=1;i<=N;i++){
cin >> L;
sum+=L;
V.push_back({sum,i});
}
sort(V.begin(),V.end());
for(int i=0;i<V.size();i++){
if(i==0 || V[i].first!=V[i-1].first)MAX++;
pa[0][V[i].second]=MAX;
}
idx[pa[0][0]]=0;
for(int i=1;i<=N;i++){
kiri[i]=idx[pa[0][i]];
idx[pa[0][i]]=i;
}
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

sumzero.cpp: In function 'int main()':
sumzero.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i=0;i<V.size();i++){
      |              ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...