#include <cstdio> #define N 300 int a[N], b[N], s[N]; int main () { int n; scanf ("%i", &n); for (int i=0; i<n; i++) { scanf ("%i", &a[i]); b[i] = a[i] - (i? s[i-1]: 0); for (int j=i; j>=0; j--) { s[j] = b[i] + (j? s[j-1]: 0); if (s[j] > a[j]) { puts ("NIE"); return 0; } } } puts ("TAK"); printf ("%i\n", n); for (int i=0; i<n; i++) printf ("%i%c", b[i], i<n-1?' ':'\n'); return 0; }
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 | #include <cstdio> #define N 300 int a[N], b[N], s[N]; int main () { int n; scanf ("%i", &n); for (int i=0; i<n; i++) { scanf ("%i", &a[i]); b[i] = a[i] - (i? s[i-1]: 0); for (int j=i; j>=0; j--) { s[j] = b[i] + (j? s[j-1]: 0); if (s[j] > a[j]) { puts ("NIE"); return 0; } } } puts ("TAK"); printf ("%i\n", n); for (int i=0; i<n; i++) printf ("%i%c", b[i], i<n-1?' ':'\n'); return 0; } |