#include<iostream> using namespace std; long long suma[307]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; long long a[n], b[n]; for(long long i = 0;i < n;i++) cin >> a[i]; b[0] = a[0]; for(long long i = 1;i < n;i++) b[i] = a[i] - a[i - 1]; for(long long i = 0;i < n;i++) suma[i + 1] = suma[i] + b[i]; for(long long i = 1;i <= n;i++) for(long long j = 0;j < n;j++) if(a[i - 1] < suma[j + i] - suma[j]){ cout << "NIE"; return 0; } cout << "TAK\n" << n << '\n'; for(auto i : b) cout << 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 | #include<iostream> using namespace std; long long suma[307]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; long long a[n], b[n]; for(long long i = 0;i < n;i++) cin >> a[i]; b[0] = a[0]; for(long long i = 1;i < n;i++) b[i] = a[i] - a[i - 1]; for(long long i = 0;i < n;i++) suma[i + 1] = suma[i] + b[i]; for(long long i = 1;i <= n;i++) for(long long j = 0;j < n;j++) if(a[i - 1] < suma[j + i] - suma[j]){ cout << "NIE"; return 0; } cout << "TAK\n" << n << '\n'; for(auto i : b) cout << i << ' '; } |