#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N = 305;
const ll malo = -10000000000000;
int n;
int a[N];
int solo;
void solve() {
vector<ll> ans, vec;
ans.pb(malo); ans.pb(solo); ans.pb(malo);
int x = -2137, y = -2137;
if (n > 1) {
x = solo;
y = a[1] - solo;
if (y > solo) {
cout << "NIE\n";
return;
}
ans.pb(x); ans.pb(y); ans.pb(malo);
}
vec.pb(x); vec.pb(y);
for (int i = 2; i < n; i ++) {
for (auto it : vec) {
ans.pb(it);
}
ll bonus = (ll) a[i] - a[i - 1];
if (bonus > solo) {
cout << "NIE\n";
return;
}
ans.pb(bonus);
vec.pb(bonus);
ans.pb(malo);
}
cout << "TAK\n";
cout << (int) ans.size() << '\n';
for (auto it : ans) cout << it << ' ';
cout << '\n';
}
int main(){
std::ios::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
cin >> n;
for (int i = 0; i < n; i ++) cin >> a[i];
solo = a[0];
solve();
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #include <bits/stdc++.h> #define pb push_back #define f first #define s second #define all(x) x.begin(), x.end() using namespace std; typedef long long ll; typedef pair<int,int> pii; const int N = 305; const ll malo = -10000000000000; int n; int a[N]; int solo; void solve() { vector<ll> ans, vec; ans.pb(malo); ans.pb(solo); ans.pb(malo); int x = -2137, y = -2137; if (n > 1) { x = solo; y = a[1] - solo; if (y > solo) { cout << "NIE\n"; return; } ans.pb(x); ans.pb(y); ans.pb(malo); } vec.pb(x); vec.pb(y); for (int i = 2; i < n; i ++) { for (auto it : vec) { ans.pb(it); } ll bonus = (ll) a[i] - a[i - 1]; if (bonus > solo) { cout << "NIE\n"; return; } ans.pb(bonus); vec.pb(bonus); ans.pb(malo); } cout << "TAK\n"; cout << (int) ans.size() << '\n'; for (auto it : ans) cout << it << ' '; cout << '\n'; } int main(){ std::ios::sync_with_stdio(false); cout.tie(0); cin.tie(0); cin >> n; for (int i = 0; i < n; i ++) cin >> a[i]; solo = a[0]; solve(); return 0; } |
English