fork(1) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int drunkOrNot(vector<pair<int, int>>& alcohol, long unsigned int limit) {
  5. long unsigned int total = 0;
  6.  
  7. for(long unsigned int i = 0; i < alcohol.size(); i++) {
  8. long unsigned int val = alcohol[i].first*alcohol[i].second/100;
  9. total += val;
  10. if(total > limit)
  11. return i + 1;
  12. }
  13. return -1;
  14. }
  15.  
  16. int main() {
  17. long unsigned int N, X;
  18. cin >> N;
  19. cin >> X;
  20.  
  21. vector<pair<int, int>> alcohol;
  22.  
  23. for(long unsigned int i = 0; i < N; i++) {
  24. int v1, v2;
  25. cin >> v1;
  26. cin >> v2;
  27. alcohol.push_back({v1, v2});
  28. }
  29.  
  30. cout << drunkOrNot(alcohol, X) << endl;
  31. }
Success #stdin #stdout 0s 4884KB
stdin
3 1000000
1000 100
1000 100
1000 100
stdout
-1