forked from 21171-somesh/CodeforcesSolutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path283A.cpp
More file actions
49 lines (47 loc) · 1003 Bytes
/
283A.cpp
File metadata and controls
49 lines (47 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//21171_somesh || asomesh999
//AC
#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define io ios::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
long int mod=1000000007;
int main()
{
io
int n;
cin >> n;
vector<pair<int, int>> numbers(1);
double sum = 0, total = 1;
while (n--) {
int queryType;
cin >> queryType;
if (queryType == 1) {
int x, a;
cin >> a >> x;
sum += x * a;
a -= 1;
numbers[a].second += x;
} else if (queryType == 2) {
int x;
cin >> x;
numbers.push_back(pair<int, int> (x, 0));
sum += x;
total++;
} else {
total--;
sum -= numbers.back().first + numbers.back().second;
int inc = numbers.back().second;
numbers.pop_back();
numbers.back().second += inc;
}
cout << fixed << setprecision(10);
cout << sum / total << '\n';
}
return 0;
}