#include <bits/stdc++.h> using namespace std; #define LL long long #define ULL unsigned LL #define LD long double int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; int a[n+1]; for(int i=1; i<=n; i++) cin>>a[i]; for(int i=1; i<=n; i++) { for(int k=1; k<i; k++) { if(a[i] > (a[k]+a[i-k])) { cout<<"NIE\n"; return 0; } } } vector<int> b; b.push_back(a[1]); for(int i=2; i<=n; i++) { b.push_back(a[i]-a[i-1]); } cout<<"TAK\n"<<n<<"\n"; for(int x : b) cout<<x<<" "; }
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 | #include <bits/stdc++.h> using namespace std; #define LL long long #define ULL unsigned LL #define LD long double int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; int a[n+1]; for(int i=1; i<=n; i++) cin>>a[i]; for(int i=1; i<=n; i++) { for(int k=1; k<i; k++) { if(a[i] > (a[k]+a[i-k])) { cout<<"NIE\n"; return 0; } } } vector<int> b; b.push_back(a[1]); for(int i=2; i<=n; i++) { b.push_back(a[i]-a[i-1]); } cout<<"TAK\n"<<n<<"\n"; for(int x : b) cout<<x<<" "; } |