제출 #1288231

#제출 시각아이디문제언어결과실행 시간메모리
1288231tunademayoLet's Win the Election (JOI22_ho_t3)C++20
5 / 100
6 ms348 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const bool Multitest = 0; const int N = 505; const ll offset = 1e9; int n, k; struct Type { ll x, y; }; Type a[N]; bool cmp1(Type a, Type b) { return b.y > 0 && a.y < b.y; } bool cmp2(Type a, Type b) { return a.x < b.x; } void work() { cin >> n >> k; for(int i = 1 ; i <= n ; i++) { cin >> a[i].x >> a[i].y; a[i].x *= offset; a[i].y *= offset; } sort(a + 1, a + 1 + n, cmp1); ll ans = 1e18, t = 0, last = 0; for(int i = 0 ; i <= k ; i++) { if(a[i].y < 0) break; if(i != 0) { ll T = (a[i].y - last + i - 1) / i; t += T; last = T * i - a[i].y; } vector<Type> b; for(int j = i + 1 ; j <= n ; j++) b.push_back(a[j]); sort(b.begin(), b.end(), cmp2); // for(auto x : b) // { // cout << x.x << ' ' << x.y << '\n'; // } ll Last = last, at = t; for(int x = 0 ; i + x < k ; x++) { ll ti = (b[x].x - Last + i) / (i + 1); // cout << i + x << ' ' << b[x].x << ' ' << Last << ' ' << i << '\n'; Last = ti * (i + 1) - b[x].x; at += ti; } ans = min(ans, at); } cout << setprecision(9) << fixed << (1.0 * ans) / offset; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int q = 1; if(Multitest) cin >> q; while(q--) work(); }
#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...