#include <iostream> using namespace std; const int N = 301; int n, a[N], b[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i=0; i<n; i++) cin >> a[i]; b[0] = a[0]; for (int i=1; i<n; i++) b[i] = a[i] - a[i-1]; bool fail = false; for (int i=0; i<n; i++) { long long sum = 0; for (int j=i; j<n; j++) { sum += b[j]; if (sum > a[j-i]) fail = true; } } if (!fail) { cout << "TAK\n" << n << "\n"; for (int i=0; i<n; i++) cout << b[i] << " "; cout << "\n"; } else cout << "NIE\n"; 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 | #include <iostream> using namespace std; const int N = 301; int n, a[N], b[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i=0; i<n; i++) cin >> a[i]; b[0] = a[0]; for (int i=1; i<n; i++) b[i] = a[i] - a[i-1]; bool fail = false; for (int i=0; i<n; i++) { long long sum = 0; for (int j=i; j<n; j++) { sum += b[j]; if (sum > a[j-i]) fail = true; } } if (!fail) { cout << "TAK\n" << n << "\n"; for (int i=0; i<n; i++) cout << b[i] << " "; cout << "\n"; } else cout << "NIE\n"; return 0; } |