#include "bits/stdc++.h" using namespace std; template <class A, class B> ostream& operator<<(ostream &os, pair<A, B> p) { return os << '{' << p.first << ", " << p.second << '}'; } template <class T> ostream& operator<<(ostream &os, vector<T> v) { os << '{'; for (T i : v) os << i << ", "; return os << '}'; } #ifdef DEBUG #define D(x...) x #else #define D(x...) #endif #define LN(x) D(cerr << #x << ": " << x << ' ') #define LOG(x) D(cerr << #x << ": " << x << '\n') #define MES(x) D(cerr << x << ' ') #define MESL(x) D(cerr << x << '\n') typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<bool> vb; typedef pair<int, int> pii; #define EB emplace_back #define PB pop_back #define fi first #define se second #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define REP(i, n) FOR(i, 0, (n) - 1) // Ignacy Boehlke int main() { int n; scanf("%d", &n); vi info(n), vec(n); REP(i, n) { scanf("%d", &info[i]); vec[i] = info[i] - (i == 0 ? 0 : info[i - 1]); REP(j, i - 1) { if (info[j] < info[i] - info[i - j - 1]) { puts("NIE"); return 0; } } } printf("TAK\n%d\n", n); REP(i, n) printf("%d ", vec[i]); printf("\n"); }
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 46 47 48 49 50 51 52 53 | #include "bits/stdc++.h" using namespace std; template <class A, class B> ostream& operator<<(ostream &os, pair<A, B> p) { return os << '{' << p.first << ", " << p.second << '}'; } template <class T> ostream& operator<<(ostream &os, vector<T> v) { os << '{'; for (T i : v) os << i << ", "; return os << '}'; } #ifdef DEBUG #define D(x...) x #else #define D(x...) #endif #define LN(x) D(cerr << #x << ": " << x << ' ') #define LOG(x) D(cerr << #x << ": " << x << '\n') #define MES(x) D(cerr << x << ' ') #define MESL(x) D(cerr << x << '\n') typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<bool> vb; typedef pair<int, int> pii; #define EB emplace_back #define PB pop_back #define fi first #define se second #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define REP(i, n) FOR(i, 0, (n) - 1) // Ignacy Boehlke int main() { int n; scanf("%d", &n); vi info(n), vec(n); REP(i, n) { scanf("%d", &info[i]); vec[i] = info[i] - (i == 0 ? 0 : info[i - 1]); REP(j, i - 1) { if (info[j] < info[i] - info[i - j - 1]) { puts("NIE"); return 0; } } } printf("TAK\n%d\n", n); REP(i, n) printf("%d ", vec[i]); printf("\n"); } |