#include "iostream" using namespace std;; int inf[305]; int odp[305]; int main(){ int n; cin>>n; bool flag = true; for(int i =1; i<=n; i++){ cin>>inf[i]; odp[i] = inf[i] - inf[i-1];; } for(int i = 1; i<=n; i++){ for(int j = i; j<=n; j++) if(inf[j] - inf[j-i] > inf[i]) flag = false; } if (flag){ cout<<"TAK\n"<<n<<"\n"; for(int i = 1; i<=n; i++) cout<<odp[i]<<" "; cout<<"\n"; } else { cout<<"NIE\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 "iostream" using namespace std;; int inf[305]; int odp[305]; int main(){ int n; cin>>n; bool flag = true; for(int i =1; i<=n; i++){ cin>>inf[i]; odp[i] = inf[i] - inf[i-1];; } for(int i = 1; i<=n; i++){ for(int j = i; j<=n; j++) if(inf[j] - inf[j-i] > inf[i]) flag = false; } if (flag){ cout<<"TAK\n"<<n<<"\n"; for(int i = 1; i<=n; i++) cout<<odp[i]<<" "; cout<<"\n"; } else { cout<<"NIE\n"; } } |