#include <iostream> using namespace std; bool isGood(int *a, int index) { if (index==0) return true; for (int i=0;i<=index/2;++i) { if (a[index]>a[i]+a[index-i-1]) return false; } return true; } int main() { int n; int *a; cin >> n; a = new int[n]; for (int i=0;i<n;++i) { cin >> a[i]; if (!isGood(a,i)) { cout << "NIE" << endl; return 0; } } cout << "TAK" << endl << n << endl << a[0]; for (int i=1;i<n;++i) cout << " " << a[i]-a[i-1]; cout << endl; 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 | #include <iostream> using namespace std; bool isGood(int *a, int index) { if (index==0) return true; for (int i=0;i<=index/2;++i) { if (a[index]>a[i]+a[index-i-1]) return false; } return true; } int main() { int n; int *a; cin >> n; a = new int[n]; for (int i=0;i<n;++i) { cin >> a[i]; if (!isGood(a,i)) { cout << "NIE" << endl; return 0; } } cout << "TAK" << endl << n << endl << a[0]; for (int i=1;i<n;++i) cout << " " << a[i]-a[i-1]; cout << endl; return 0; } |