Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <map>
- #include <vector>
- using namespace std;
- long long tuy[100111];
- int main() {
- long long n; cin >> n;
- map<string, vector<long long >>pmh;
- long long ww = 1;
- for (int ttt = 0; ttt < n; ttt++) {
- string s;
- cin >> s;
- if (s == "delete") {
- long long ttttq; cin >> ttttq;
- for (int j = ww - 1; j >= 1; j--) {
- if (tuy[j] <= ttttq) {
- ttttq -= tuy[j];
- tuy[j] = 0;
- }
- else {
- tuy[j] -= ttttq;
- ttttq = 0;
- }
- if (ttttq == 0)
- break;
- }
- }
- if (s == "get") {
- string imi;
- cin >> imi;
- long long anssss = 0;
- for (auto x : pmh[imi]) {
- anssss += tuy[x];
- }
- cout << anssss << endl;
- }
- if (s == "add") {
- long long eqw;
- cin >> eqw;
- string name;
- cin >> name;
- pmh[name].push_back(ww);
- tuy[ww] = eqw;
- ww++;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement