// Karol Kosinski 2020 #include <cstdio> #define FOR(i,a,b) for(int i=(a);i<(b);++i) //#define DEBUG(x...) printf(x) #define DEBUG(x...) using namespace std; const int NX = 303; int A[NX]; bool check(int n) { FOR(i,2,n) FOR(k,1,i) { DEBUG("A[%d] = %d <= %d + %d = A[%d] + A[%d]\n", i, A[i], A[k], A[i-k], k, i-k); if (A[i] > A[k] + A[i-k]) return false; } return true; } int main() { int n; scanf("%d", &n); ++ n; FOR(i,1,n) scanf("%d", A + i); if (check(n)) { printf("TAK\n%d\n", n - 1); FOR(i,1,n) printf("%d ", A[i] - A[i-1]); printf("\n"); return 0; } printf("NIE\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 30 31 32 33 34 35 36 37 38 | // Karol Kosinski 2020 #include <cstdio> #define FOR(i,a,b) for(int i=(a);i<(b);++i) //#define DEBUG(x...) printf(x) #define DEBUG(x...) using namespace std; const int NX = 303; int A[NX]; bool check(int n) { FOR(i,2,n) FOR(k,1,i) { DEBUG("A[%d] = %d <= %d + %d = A[%d] + A[%d]\n", i, A[i], A[k], A[i-k], k, i-k); if (A[i] > A[k] + A[i-k]) return false; } return true; } int main() { int n; scanf("%d", &n); ++ n; FOR(i,1,n) scanf("%d", A + i); if (check(n)) { printf("TAK\n%d\n", n - 1); FOR(i,1,n) printf("%d ", A[i] - A[i-1]); printf("\n"); return 0; } printf("NIE\n"); return 0; } |