Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4. #include <vector>
  5.  
  6.  
  7. using namespace std;
  8. long long tuy[100111];
  9. int main() {
  10. long long n; cin >> n;
  11. map<string, vector<long long >>pmh;
  12. long long ww = 1;
  13. for (int ttt = 0; ttt < n; ttt++) {
  14. string s;
  15. cin >> s;
  16. if (s == "delete") {
  17. long long ttttq; cin >> ttttq;
  18. for (int j = ww - 1; j >= 1; j--) {
  19. if (tuy[j] <= ttttq) {
  20. ttttq -= tuy[j];
  21. tuy[j] = 0;
  22. }
  23. else {
  24. tuy[j] -= ttttq;
  25. ttttq = 0;
  26. }
  27. if (ttttq == 0)
  28. break;
  29. }
  30. }
  31. if (s == "get") {
  32. string imi;
  33. cin >> imi;
  34. long long anssss = 0;
  35. for (auto x : pmh[imi]) {
  36. anssss += tuy[x];
  37. }
  38. cout << anssss << endl;
  39. }
  40. if (s == "add") {
  41. long long eqw;
  42. cin >> eqw;
  43. string name;
  44. cin >> name;
  45. pmh[name].push_back(ww);
  46. tuy[ww] = eqw;
  47. ww++;
  48. }
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement