#include <bits/stdc++.h>
using namespace std;
int n, tab[310];
int wyj[310], pref[310];
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
cin>>n;
for(int i=0; i<n; ++i)cin>>tab[i];
wyj[0]=tab[0];
pref[0]=0;
pref[1]=wyj[0];
for(int i=1; i<n; ++i)
{
wyj[i]=tab[i]-tab[i-1];
pref[i+1]=pref[i]+wyj[i];
for(int j=1; j<=i+1; ++j)
{
if(pref[i+1]-pref[i+1-j]>tab[j-1])
{
cout<<"NIE\n";
return 0;
}
}
}
cout<<"TAK\n"<<n<<"\n";
for(int i=0; i<n; ++i)
{
cout<<wyj[i]<<" ";
}
cout<<"\n";
}
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 n, tab[310]; int wyj[310], pref[310]; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin>>n; for(int i=0; i<n; ++i)cin>>tab[i]; wyj[0]=tab[0]; pref[0]=0; pref[1]=wyj[0]; for(int i=1; i<n; ++i) { wyj[i]=tab[i]-tab[i-1]; pref[i+1]=pref[i]+wyj[i]; for(int j=1; j<=i+1; ++j) { if(pref[i+1]-pref[i+1-j]>tab[j-1]) { cout<<"NIE\n"; return 0; } } } cout<<"TAK\n"<<n<<"\n"; for(int i=0; i<n; ++i) { cout<<wyj[i]<<" "; } cout<<"\n"; } |
English