#include <bits/stdc++.h> using namespace std; long long n; vector<long long> v; bool check() { for (long long k = 0; k < n; k++) for (long long i = 0; 2 * i < k; i++) if (v[i] + v[k - i - 1] < v[k]) return false; return true; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; v.resize(n); for (long long& i : v) cin >> i; if (check()) { cout << "TAK\n" << n << '\n' << v[0]; for (long long i = 1; i < n; i++) cout << ' ' << v[i] - v[i - 1]; 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 35 | #include <bits/stdc++.h> using namespace std; long long n; vector<long long> v; bool check() { for (long long k = 0; k < n; k++) for (long long i = 0; 2 * i < k; i++) if (v[i] + v[k - i - 1] < v[k]) return false; return true; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; v.resize(n); for (long long& i : v) cin >> i; if (check()) { cout << "TAK\n" << n << '\n' << v[0]; for (long long i = 1; i < n; i++) cout << ' ' << v[i] - v[i - 1]; cout << '\n'; } else cout << "NIE\n"; } |