-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path114.cpp
49 lines (47 loc) · 988 Bytes
/
114.cpp
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
/*
*NAME:telecasting station
*LANG:C++
*Source:sgu114
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
int n;
pair<int,double> city[15100];;
long long sum=0,sum1=0;
int main(){
cin >> n;
for (int i=0;i<n;++i){
cin >> city[i].first >> city[i].second;
sum+=city[i].second;
}
sort(city,city+n);
for (int i=0;i<n;++i){
long long before = sum1;
sum1+=city[i].second;
if (sum1==sum/2 && sum%2==0){
cout << setiosflags(ios::fixed)
<< setprecision(5)
<< (double)(city[i].first+city[i+1].first)/2 << endl;
return 0;
}
if (sum1==((sum+1)/2) && sum%2==1){
cout << setiosflags(ios::fixed)
<< setprecision(5)
<< (double)city[i].first << endl;
return 0;
}
if (before<sum/2 && sum1>sum/2){
cout << setiosflags(ios::fixed)
<< setprecision(5)
<< (double)city[i].first << endl;
return 0;
}
}
return 0;
}