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>
using namespace std;
int tim , aa , chek[501] , here;
pair<pair<double , double> , int> one[501] , two[501];
double ans , cur , jog;
int main() {
cin >> aa >> tim;
for( int z = 0; z < aa; z++ ) {
cin >> one[z].first.first >> one[z].first.second;
if( one[z].first.second == -1 ) one[z].first.second = (double)100000000;
one[z].second = z;
two[z].second = z;
two[z].first.first = one[z].first.second;
two[z].first.second = (one[z].first.first * (double)(-1)) ;
}
sort(one , one + aa ) ;
sort( two , two + aa );
for( int z = 0; z < tim; z++ ) ans += one[z].first.first;
for( int z = 0; z < tim; z++ ) {
cur += two[z].first.first / (double)(z + 1) ;
chek[two[z].second] = 1;
here = 0;
jog = 0;
for( int y = 0; y < aa; y++ ) {
if( here + (z + 1) < tim && chek[one[y].second] != 1 ) {
here++;
jog += one[y].first.first / (double)(z + 2);
}
}
ans = min( ans , cur + jog );
}
cout << ans;
return 0;
}
# | 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... |