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