Skip to content

Instantly share code, notes, and snippets.

@awg01
Created June 29, 2019 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awg01/0578443ea858c409dbc130d5ea1e9f8f to your computer and use it in GitHub Desktop.
Save awg01/0578443ea858c409dbc130d5ea1e9f8f to your computer and use it in GitHub Desktop.
Code is giving correct answer after running on IDE.But doesn't get accepted by codechef.
/*
https://www.codechef.com/LTIME73B/problems/SILLYPRS
*/
#include <iostream>
using namespace std;
int main()
{
int t,n;
cin>>t;
for(int i=0; i<t; i++)
{
cin>>n;
int A[n],B[n],sum=0;;
int item;
int start=0, end=n-1;
for(int k=0; k<n; k++)
{
cin>>item;
if(item%2==0)
{
A[start]=item;
start++;
}
else
{
A[end]=item;
end--;
}
}
start=0, end=n-1;
for(int k=0; k<n; k++)
{
cin>>item;
if(item%2==0)
{
B[start]=item;
start++;
}
else
{
B[end]=item;
end--;
}
}
for(int i=0; i<n; i++)
{
sum= sum+(A[i]+B[i])/2;
}
cout<<sum<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment