-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path690C.cpp
More file actions
60 lines (58 loc) · 1.24 KB
/
690C.cpp
File metadata and controls
60 lines (58 loc) · 1.24 KB
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
50
51
52
53
54
55
56
57
58
59
60
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int n, m;
scanf("%d %d", &n, &m);
vector<int>arr(n);
vector<int>arr2(n);
for (int i = 0; i <n; i++)
{
scanf("%d", &arr[i]);
arr2[i] = arr[i];
}
vector<int>arr3(n);
double ans = 0;
int r;
double p;
sort(arr2.begin(),arr2.end());
int k = 1000000;
bool ys = false;
double c;
if(arr==arr2){
c = 1.0;
ys = true;
}
while (m--)
{
scanf("%d %lf", &r, &p);
if(ys)continue;
if(r < k){
arr3 = arr;
sort(arr3.begin(),arr3.begin()+r);
}
if(arr3==arr2 || r>= k){
if(k > r){
k = r;
}
if(abs(ans+0)<= 1e-8){
ans = p;
}
else
{
ans = ans + p - (ans*p);
}
}
}
if(ys){
printf("%lf\n",c);
}
else{
printf("%lf\n",ans);
}
}
}