#include<bits/stdc++.h> #define int long long using namespace std; const int N = 305; int n, m, a[N], b[N], p[N]; main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; b[i] = a[i] - a[i - 1]; p[i] = p[i - 1] + b[i]; } for(int sz = 1; sz <= n; sz++){ int mx = -1e18; for(int i = 1; i + sz - 1 <= n; i++){ int j = i + sz - 1; int val = p[j] - p[i - 1]; mx = max(mx, val); } if(mx != a[sz]){ cout << "NIE\n"; return 0; } } cout << "TAK\n"; cout << n << "\n"; for(int i = 1; i <= n; i++){ cout << b[i] << " "; } }
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 36 | #include<bits/stdc++.h> #define int long long using namespace std; const int N = 305; int n, m, a[N], b[N], p[N]; main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; b[i] = a[i] - a[i - 1]; p[i] = p[i - 1] + b[i]; } for(int sz = 1; sz <= n; sz++){ int mx = -1e18; for(int i = 1; i + sz - 1 <= n; i++){ int j = i + sz - 1; int val = p[j] - p[i - 1]; mx = max(mx, val); } if(mx != a[sz]){ cout << "NIE\n"; return 0; } } cout << "TAK\n"; cout << n << "\n"; for(int i = 1; i <= n; i++){ cout << b[i] << " "; } } |