Created
June 29, 2019 18:09
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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