bzoj上的坑题……
数组要放大,必须开long long
#include<cstdio> #include<algorithm> using namespace std; struct Go{ long long add,dec,rev; long long i; friend bool operator<(Go a,Go b){ if(a.rev>=0 && b.rev>=0){return a.dec<b.dec;} if(a.rev<0 && b.rev<0){return a.add>b.add;} if(a.rev>=0 && b.rev<0)return 1; if(a.rev<0 && b.rev>=0)return 0; } }da[1000005]; long long n,z; int main(){ freopen("3709.in","r",stdin); freopen("3709.out","w",stdout); scanf("%lld %lld",&n,&z); for(long long i=1;i<=n;i++)scanf("%lld %lld",&da[i].dec,&da[i].add),da[i].rev=da[i].add-da[i].dec,da[i].i=i; sort(da+1,da+1+n); for(long long i=1;i<=n;i++){ z-=da[i].dec; if(z<=0){puts("NIE");return 0;} z+=da[i].add; } puts("TAK"); for(long long i=1;i<=n;i++)printf("%lld ",da[i].i); return 0; }