You should probably find the distance and apply Pythagoras theoremâŚ
According to your solution , think like this -Two scalene triangle can also be on same coordinates. I hope you get it .
Problem Code - MAXORSUM
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long n,m;
cin>>n>>m;
int arr[n];
int brr[n];
// the maximum output will be if i apply the xor on starting m elements //
long long i,j;
for(i=0;i<n;i++)
{
cin>>arr[i];
}
for(j=0;j<n;j++)
{
cin>>brr[j];
}
// now⌠i will remove the first m elements of arr[] and find the sum
long long sum = 0;
for(i=m;i<n;i++)
{
sum = sum + arr[i];
}
cout<<sum<<endl;
}
Why i am getting Runtime Error - SIGEMT
The logic might be incorrectâŚbut why Runtime Error ?
i was trying the question of rainbow array in beginnerâs section and hereâs my code:-
try:
t=int(input())
li=[1,2,3,4,5,6,7,8,9,10]
l=[];y=''
is_this_true=True
for i in range(t):
le=int(input())
l+=map(int,input().split())
cnt=l.count(7)
mid =le//2
for k in l:
if k not in li:
is_this_true=False
break
for j in range(mid):
if (l[mid-j]==l[mid+j]) and (l[j]+1==l[j+1] or l[j]==l[j+1]) and (is_this_true) and l[mid]==7 and cnt%2!=0:
y="yes"
else:
y="no"
break
print(y)
l=[]
except:
pass
i donât know what is wrong with this code.Please help!!
i tried the suggested input in following code:-
t=int(input())
li=[1,2,3,4,5,6,7]
y=ââ;l=[]
is_this_true=True
for i in range(t):
le=int(input())
l+=(map(int,input().split()))
mid =le//2
for k in li:
if k not in l:
is_this_true=False
break
for j in range(mid):
if (l[mid-j]==l[mid+j]) and (l[j]+1==l[j+1] or l[j]==l[j+1]) and (is_this_true) and l[mid]==7:
y=âyesâ
else:
y=ânoâ
break
print(y)
l=[]
is the answer ânoâ for this input??
this is a partially correct answer, I am not getting the cases that might give errorâŚplease suggest some cases that might go wrong in this code of " chef and pairs" https://www.codechef.com/viewsolution/56786343