-
Notifications
You must be signed in to change notification settings - Fork 287
/
Copy pathqabc.cpp
42 lines (41 loc) · 815 Bytes
/
qabc.cpp
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
35
36
37
38
39
40
41
42
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int n,d=0,f=1;
cin>>n;
int a[n], b[n];
for(int i=1; i<=n; i++)
{
cin>>a[i];
}
for(int i=1; i<=n; i++)
{
cin>>b[i];
}
for(int i=1; i<=n-2; i++)
{
if(a[i]<b[i] || a[i]==b[i])
{
d=b[i]-a[i];
a[i]=a[i]+d;
a[i+1]=a[i+1]+(2*d);
a[i+2]=a[i+2]+(3*d);
}
else
{
f=0;
break;
}
}
if(f!=1 || a[n]!=b[n] || a[n-1]!=b[n-1])
cout<<"NIE"<<"\n";
else
cout<<"TAK"<<"\n";
}
return 0;
}