Unfortunately we were unable to fully decode your file, as it is not encoded in UTF-8.
You can try to decode it yourself by downloading it here.
// Micha� Figlus #include<cstdio> #include<cmath> #include<cstring> #include<cstdlib> #include<iostream> #include<fstream> #include<vector> #include<queue> #include<stack> #include<list> #include<algorithm> using namespace std; int main() { int n,i,d,a; long long z; bool p=true; vector<pair<int,pair<int,int> > > x; vector<pair<int,pair<int,int> > > y; scanf("%d%lld",&n,&z); for(i=1;i<=n;i++) { scanf("%d%d",&d,&a); if(a>=d) x.push_back(make_pair(d,make_pair(a,i))); else y.push_back(make_pair(a,make_pair(d,i))); } sort(x.begin(),x.end()); sort(y.begin(),y.end()); reverse(y.begin(),y.end()); a=x.size(); for(i=0;i<a&&p;i++) { if(z>x[i].first) z+=(x[i].second.first-x[i].first); else p=false; } d=y.size(); for(i=0;i<d&&p;i++) { if(z>y[i].second.first) z+=(y[i].first-y[i].second.first); else p=false; } if(p) { printf("TAK\n"); for(i=0;i<a;i++) printf("%d ",x[i].second.second); for(i=0;i<d;i++) printf("%d ",y[i].second.second); } else printf("NIE"); 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 | // Micha� Figlus #include<cstdio> #include<cmath> #include<cstring> #include<cstdlib> #include<iostream> #include<fstream> #include<vector> #include<queue> #include<stack> #include<list> #include<algorithm> using namespace std; int main() { int n,i,d,a; long long z; bool p=true; vector<pair<int,pair<int,int> > > x; vector<pair<int,pair<int,int> > > y; scanf("%d%lld",&n,&z); for(i=1;i<=n;i++) { scanf("%d%d",&d,&a); if(a>=d) x.push_back(make_pair(d,make_pair(a,i))); else y.push_back(make_pair(a,make_pair(d,i))); } sort(x.begin(),x.end()); sort(y.begin(),y.end()); reverse(y.begin(),y.end()); a=x.size(); for(i=0;i<a&&p;i++) { if(z>x[i].first) z+=(x[i].second.first-x[i].first); else p=false; } d=y.size(); for(i=0;i<d&&p;i++) { if(z>y[i].second.first) z+=(y[i].first-y[i].second.first); else p=false; } if(p) { printf("TAK\n"); for(i=0;i<a;i++) printf("%d ",x[i].second.second); for(i=0;i<d;i++) printf("%d ",y[i].second.second); } else printf("NIE"); return 0; } |