forked from EnigmaVSSUT/CompetitiveCoding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPAIRSUM2.cpp
More file actions
34 lines (33 loc) · 782 Bytes
/
PAIRSUM2.cpp
File metadata and controls
34 lines (33 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<bits/stdc++.h>
using namespace std;
int main(){
long long t,n,p,q,m,i,j,k,sum,count,x,y;
cin>>t;
while(t--){
cin>>n>>m;sum=0;
long long b[n];b[0]=0;
for(i=1;i<n;i++)
cin>>b[i];
while(m--){
sum=0;
count=0;
cin>>p>>q;
x=p<q?p:q;
y=p>q?p:q;
if((y-x)%2==0)
cout<<"UNKNOWN"<<endl;
else{
for(i=x;i<y;i++)
{
if((count%2)==0)
sum=sum+b[i];
else
sum=sum-b[i];
count++;
}
cout<<sum<<endl;
}
}
}
return(0);
}