Guest User

Untitled

a guest
Aug 14th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include<cstdio>
  2.  
  3. using namespace std;
  4.  
  5. int m,n,u,f,d,sum,ans;
  6. char str[2];
  7.  
  8. int main(){
  9. int i,j,k;
  10. scanf("%d %d %d %d %d",&m,&n,&u,&f,&d);
  11. u+=d;
  12. d+=u;
  13. f*=2;
  14. sum=0;
  15. ans=0;
  16. for(i=0;i<n;i++){
  17. scanf("%s",&str);
  18. if (str[0]=='u'){
  19. sum+=u;
  20. }else if (str[0]=='f'){
  21. sum+=f;
  22. }else{
  23. sum+=d;
  24. }
  25. if (sum<=m) ans=i+1;
  26. }
  27. printf("%d\n",ans);
  28. return 0;
  29. }
Add Comment
Please, Sign In to add comment