# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
806697 | 2023-08-04T08:58:39 Z | vjudge1 | Let's Win the Election (JOI22_ho_t3) | C++14 | 1402 ms | 3256 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Incorrect | 0 ms | 212 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1402 ms | 3256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Incorrect | 0 ms | 212 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |