# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
806698 | vjudge1 | Let's Win the Election (JOI22_ho_t3) | C++14 | 987 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define fi first
#define se second
#define ld long double
using namespace std ;
const int N = 500 ;
int n, k ;
ld a[N + 1], b[N + 1] ;
vector<pair<int, int>> v_neg, v_pos ;
signed main()
{
ios_base::sync_with_stdio( 0 ) ;
cin.tie( 0 ) ;
cout.tie( 0 ) ;
cin >> n >> k ;
for(int i = 1 ; i <= n ; i++)
{
cin >> a[i] >> b[i] ;
if(b[i] == -1)
v_neg.push_back({a[i], b[i]}) ;
else
v_pos.push_back({a[i], b[i]}) ;
}
sort(v_pos.begin(), v_pos.end()) ;
sort(v_neg.begin(), v_neg.end()) ;
if(!v_pos.size())
{
ld ans = 0 ;
for(int i = 0 ; i < k ; i++)
ans += v_neg[i].fi ;
cout << fixed << setprecision(11) << ans ;
return 0 ;
}
ld ans = 1e9 ;
for(int i = 0 ; i < v_pos.size() ; i++)
{
for(int j = i ; j < v_pos.size() ; j++)
{
vector<pair<int, int>> abu ;
ld cnt = 1, sum = 0 ;
for(int q = i ; q <= j ; q++)
abu.push_back({v_pos[q].se, v_pos[q].fi}) ;
sort(abu.begin(), abu.end()) ;
for(int i = 0 ; i < abu.size() ; i++)
{
sum += abu[i].fi / cnt ;
cnt++ ;
}
// cout << sum << ' ' ;
for(int q = 0 ; q < i ; q++)
sum += v_pos[q].fi / cnt ;
for(int q = j + 1 ; q < v_pos.size() ; q++)
sum += v_pos[q].fi / cnt ;
for(int q = 0 ; q < v_neg.size() ; q++)
sum += v_neg[q].fi / cnt ;
// cout << i << ' ' << j << ' '<< sum << '\n' ;
ans = min(ans, sum) ;
}
}
cout << fixed << setprecision(11) << ans ;
return 0 ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |