제출 #1000855

#제출 시각아이디문제언어결과실행 시간메모리
1000855walizamaneeLet's Win the Election (JOI22_ho_t3)C++17
10 / 100
1 ms424 KiB


#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...