fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n,k, cnt=0, cur=0;
  6. string str;
  7. cin>>n>>k;
  8.  
  9. for(int i=0;i<n;i++){
  10. cin>>str;
  11.  
  12. if(str=="save"){
  13. cnt=cur;
  14. cout<<cnt<<'\n';
  15. }
  16. else if(str=="load"){
  17. cur=cnt;
  18. cout<<cur<<'\n';
  19. }
  20. else if(str=="shoot"){
  21. cur-=1;
  22. cout<<cur<<'\n';
  23. }
  24. else{
  25. cur+=k;
  26. cout<<cur<<'\n';
  27. }
  28. }
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 5324KB
stdin
7 3
ammo
save
shoot
ammo
load
shoot
load
stdout
3
3
2
5
3
2
3