#include <iostream> using namespace std; int t[400],n, ok=1; int main() { cin >> n; for(int i=1;i<=n;i++) cin >> t[i]; for(int k=2;k<=n;k++) for(int i=1;i<k;i++) if(t[i]+t[k-i]< t[k]) ok = 0; if(!ok) cout << "NIE\n"; else { cout << "TAK\n"; cout << n << "\n"; for(int i=1;i<=n;i++) cout << t[i]-t[i-1] << " "; cout << "\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 | #include <iostream> using namespace std; int t[400],n, ok=1; int main() { cin >> n; for(int i=1;i<=n;i++) cin >> t[i]; for(int k=2;k<=n;k++) for(int i=1;i<k;i++) if(t[i]+t[k-i]< t[k]) ok = 0; if(!ok) cout << "NIE\n"; else { cout << "TAK\n"; cout << n << "\n"; for(int i=1;i<=n;i++) cout << t[i]-t[i-1] << " "; cout << "\n"; } } |