#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef LOCAL
#define debug(...) __VA_ARGS__
#else
#define debug(...) {}
#endif
const ll INF = -1e13;
int main(){
ios_base::sync_with_stdio(0);
cin.tie();
cout.tie();
int i;
int n;
cin>>n;
vector<int> prev;
vector<ll> answ;
int pop = 0;
for (i = 1; i < n+1; i++){
int akt;
cin>>akt;
for (int j : prev) answ.push_back(j);
int pref = 0;
int suf = 0;
for (int j = 0; j < i-1; j++){
pref += prev[j];
//cout<<i<<" "<<j<<" "<<pref<<" "<<suf<<" "<<akt<<"\n";
if (akt-pop > pref-suf){
cout<<"NIE\n";
return 0;
}
suf += prev[prev.size()-j-1];
}
pop = akt;
prev.push_back(akt-pref);
answ.push_back(akt-pref);
answ.push_back(INF);
}
cout<<"TAK\n"<<answ.size()<<"\n";
for (ll j : answ) cout<<j<<" ";
cout<<"\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 39 40 41 42 43 44 | #include <bits/stdc++.h> using namespace std; typedef long long ll; #ifdef LOCAL #define debug(...) __VA_ARGS__ #else #define debug(...) {} #endif const ll INF = -1e13; int main(){ ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); int i; int n; cin>>n; vector<int> prev; vector<ll> answ; int pop = 0; for (i = 1; i < n+1; i++){ int akt; cin>>akt; for (int j : prev) answ.push_back(j); int pref = 0; int suf = 0; for (int j = 0; j < i-1; j++){ pref += prev[j]; //cout<<i<<" "<<j<<" "<<pref<<" "<<suf<<" "<<akt<<"\n"; if (akt-pop > pref-suf){ cout<<"NIE\n"; return 0; } suf += prev[prev.size()-j-1]; } pop = akt; prev.push_back(akt-pref); answ.push_back(akt-pref); answ.push_back(INF); } cout<<"TAK\n"<<answ.size()<<"\n"; for (ll j : answ) cout<<j<<" "; cout<<"\n"; return 0; } |
English