5 solutions
-
0
#include<bits/stdc++.h> using namespace std; int main() { bool jud=true; int n,x,k=0,s=0; cin>>n>>x; x*=100;//不等式左右两边同时乘100 for(int i=1;i<=n;i++) { int v,p; cin>>v>>p; //s+=v*p/100.0;//由于C++存在浮点数精度误差,所以这样算可能会得到错误的结果。 s+=v*p; if(s>x && jud) { k=i; jud=false; break; } } if(jud) cout<<-1; else cout<<k; return 0; }
Information
- ID
- 2368
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 1
- Tags
- (None)
- # Submissions
- 130
- Accepted
- 31
- Uploaded By