#include <bits/stdc++.h> using namespace std; const int N = 307; int a[N]; int c[N * 10]; int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); ////maybe int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int v = 0; for (int i = 1; i <= n; i++){ c[i] = a[i] - v; v += c[i]; } for (int i = 1; i <= n; i++){ int l = 1, r = 1, w = c[1]; while (true) { if (!(r - l + 1 < i)) break; r++; w += c[i]; } while (r <= n){ if (w > a[i]){ cout << "NIE\n"; return 0; } w -= c[l]; l++, r++; w += c[r]; } } cout << "TAK\n"; cout << n << "\n"; for (int i = 1; i <= n; i++){ cout << c[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 37 38 39 40 41 42 43 44 45 | #include <bits/stdc++.h> using namespace std; const int N = 307; int a[N]; int c[N * 10]; int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); ////maybe int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int v = 0; for (int i = 1; i <= n; i++){ c[i] = a[i] - v; v += c[i]; } for (int i = 1; i <= n; i++){ int l = 1, r = 1, w = c[1]; while (true) { if (!(r - l + 1 < i)) break; r++; w += c[i]; } while (r <= n){ if (w > a[i]){ cout << "NIE\n"; return 0; } w -= c[l]; l++, r++; w += c[r]; } } cout << "TAK\n"; cout << n << "\n"; for (int i = 1; i <= n; i++){ cout << c[i] << " "; } } |