Advertisement
Guest User

Untitled

a guest
May 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. inline int GCD (int a, int b) { return b == 0 ? a : GCD(b, a % b); }
  4. inline int LCM (int a, int b) { return a * b / GCD(a, b); }
  5. #define endl '\n';
  6. #define WHILE(n) while(n--)
  7. #define pb push_back
  8. #define PI acos(-1)
  9. typedef pair<int, int> pii;
  10. typedef long long ll;
  11. typedef long double ld;
  12. typedef long long int lli;
  13. typedef unsigned long long ull;
  14. bool isable[100001];
  15. int mules[100001];
  16. int main(){
  17. cin.sync_with_stdio(0);
  18. cin.tie(0);
  19. int t, n, c;
  20. cin >> t;
  21. WHILE(t){
  22. fill_n(mules, 10001, 0);
  23. fill_n(isable, 1001, false);
  24. cin >> n >> c;
  25. WHILE(c){
  26. string d; int a, b;
  27. cin >> d;
  28. if(d == "A"){
  29. cin >> a >> b;
  30. if(isable[b] != true){
  31. mules[b] += a;
  32. }
  33. }
  34. else if(d == "Q"){cin >> a; cout << mules[a] << endl;}
  35. else if(d == "G"){
  36. cin >> a;
  37. int tot = 0;
  38. for(int i = 1; i <= a; i++){
  39. tot += mules[i];
  40. }
  41. cout << tot << endl;
  42. }
  43. else if(d == "L"){
  44. cin >> a;
  45. int tot = 0;
  46. for(int i = n+1; i > n-a; i--){
  47. tot += mules[i];
  48. }
  49. cout << tot << endl;
  50. }
  51. else if(d == "Covfefe"){
  52. cin >> a;
  53. isable[a] = true;
  54. mules[a] = 0;
  55. }
  56. }
  57. }
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement