#include<bits/stdc++.h>
using namespace std;
long long tab[305];
long long res[305];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int a;
cin>>a;
for(int x=1;x<=a;x++)
{
cin>>tab[x];
res[x] = tab[x] - tab[x-1];
}
for(int x=1;x<=a;x++)
{
long long siema = 0;
for(int y=1;y<=x;y++)
siema += res[y];
for(int y=x+1;y<=a;y++)
{
siema -= res[y-x];
siema += res[y];
if(siema > tab[x])
{
cout<<"NIE";
return 0;
}
}
}
cout<<"TAK"<<'\n'<<a<<'\n';
for(int x=1;x<=a;x++)
cout<<res[x]<<" ";
return 0;
}
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 | #include<bits/stdc++.h> using namespace std; long long tab[305]; long long res[305]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int a; cin>>a; for(int x=1;x<=a;x++) { cin>>tab[x]; res[x] = tab[x] - tab[x-1]; } for(int x=1;x<=a;x++) { long long siema = 0; for(int y=1;y<=x;y++) siema += res[y]; for(int y=x+1;y<=a;y++) { siema -= res[y-x]; siema += res[y]; if(siema > tab[x]) { cout<<"NIE"; return 0; } } } cout<<"TAK"<<'\n'<<a<<'\n'; for(int x=1;x<=a;x++) cout<<res[x]<<" "; return 0; } |
English