#include
#include
#include
using namespace std;
int main() {
// your code goes here
int N;
cin>>N;
vector S;
int x;
for(int i=0;i<N;i++)
{
cin>>x;
S.push_back(x);
}
map<int,int> abc;
map<int,int> def;
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
for(int k=0;k<N;k++)
{
int temp=S[i]*S[j]+S[k];
if(abc.find(temp)!=abc.end())
abc[temp]++;
else
abc[temp]=1;
}
}
}
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
for(int k=0;k<N;k++)
{
if(S[k]!=0)
{
int temp=(S[i]+S[j])S[k];
if(def.find(temp)!=def.end())
def[temp]++;
else
def[temp]=1;
}
}
}
}
int count=0;
for(auto it=abc.begin();it!=abc.end();it++)
{
int key=it->first;
int value=it->second;
if(def.find(key)!=def.end())
count=count+(valuedef[key]);
else
continue;
}
return count;
}
I have created two arrays abc def which holds the possible values in maps then added to get the final answer.However when I run in codeblocks I get correct output,but on spoj getting runtime error NZEC.
Please guide me through this.