Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<list>
- #include<algorithm>
- #include <iomanip>
- #include <map>
- using namespace std;
- int main(){
- int a;
- cin>>a;
- map<string,int>m;
- int b;
- string w;
- int x;
- double t=0;
- int k=0;
- for(int i=0;i<a;i++){
- cin>>b;
- if(b == 1){
- cin>>w>>x;
- if(m[w] == 0){
- k++;
- }
- m[w] = m[w] + x;
- t = t + x;
- }
- else if(b == 2){
- cin>>w;
- t = t - m[w];
- m[w] = 0;
- k--;
- }
- else{
- cin>>w;
- cout<<m[w]<<endl;
- }
- }
- if(k != 0){
- t = t / k;
- }
- cout<<setprecision(2)<<fixed<<t;
- return 0;
- }
Add Comment
Please, Sign In to add comment