来源:酒
酒
思路:s累加量乘浓度,然后到s>x*100时输出i,没醉输出-1,如果用累加量乘浓度/100.0和x比会出精度错误。
代码
#include<bits/stdc++.h>
using namespace std;
long long n,x,v,p,s,i;
int main(){
scanf("%lld%lld",&n,&x);
for(i=1;i<=n;i++){
scanf("%lld%lld",&v,&p);
s+=v*p;
if(s>x*100){
printf("%lld",i);
return 0;
}
}
printf("-1");
}