Submission #806698

#TimeUsernameProblemLanguageResultExecution timeMemory
806698vjudge1Let's Win the Election (JOI22_ho_t3)C++14
5 / 100
987 ms384 KiB
#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)

Main.cpp: In function 'int main()':
Main.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i = 0 ; i < v_pos.size() ; i++)
      |                     ~~^~~~~~~~~~~~~~
Main.cpp:37:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int j = i ; j < v_pos.size() ; j++)
      |                         ~~^~~~~~~~~~~~~~
Main.cpp:44:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             for(int i = 0 ; i < abu.size() ; i++)
      |                             ~~^~~~~~~~~~~~
Main.cpp:52:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |             for(int q = j + 1 ; q < v_pos.size() ; q++)
      |                                 ~~^~~~~~~~~~~~~~
Main.cpp:54:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |             for(int q = 0 ; q < v_neg.size() ; q++)
      |                             ~~^~~~~~~~~~~~~~
#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...