2
13
2016
0

[BZOJ3709] [PA2014]Bohater

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;
}
Category: BZOJ | Tags: OI bzoj | Read Count: 523

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com