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