fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define fi first
  5. #define se second
  6. #define _CUONGKC_ int main()
  7. int main(){
  8. ios::sync_with_stdio(false);
  9. cin.tie(NULL);
  10. int N;
  11. cin >> N;
  12. ll touches=0;
  13. int cur=0;
  14. for(int i=0;i<N;i++){
  15. char cmd;
  16. ll x;
  17. cin >> cmd >> x;
  18. if(cmd=='R'){
  19. touches+=(cur+x)/100;
  20. cur=(cur+(x%100))%100;
  21. }else{
  22. if(cur == 0){
  23. touches+=x/100;
  24. }else{
  25. if(x>=cur){
  26. touches++;
  27. ll x_rem=x-cur;
  28. touches+=x_rem/100;
  29. }
  30. }
  31. cur=(cur-(x%100)+100)%100;
  32. }
  33. }
  34. cout << touches;
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0.01s 5284KB
stdin
5
L 5
R 10
L 5
R 120
L 40
stdout
4