Submission #934510

#TimeUsernameProblemLanguageResultExecution timeMemory
934510Amirreza_FakhriSure Bet (CEOI17_sure)C++17
0 / 100
1 ms2396 KiB
// In the name of the God #include <bits/stdc++.h> #define ll long long // #define int long long #define pb push_back #define F first #define S second #define mp make_pair #define pii pair <int, int> #define smin(x, y) (x) = min((x), (y)) #define smax(x, y) (x) = max((x), (y)) #define all(x) (x).begin(), (x).end() using namespace std; const int inf = 1e9+7; const int mod = 998244353; const int maxn = 1e5+5; int n; double a[maxn], b[maxn], pa[maxn], pb[maxn]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << fixed << setprecision(4); cin >> n; for (int i = 0; i < n; i++) cin >> a[i] >> b[i]; sort(a, a+n), sort(b, b+n); reverse(a, a+n), reverse(b, b+n); for (int i = 0; i < n; i++) { pa[i] = a[i], pb[i] = b[i]; if (i) pa[i] += pa[i-1], pb[i] += pb[i-1]; } double ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { double cost = i+j+2; if (pa[i] < pb[j]) smax(ans, min(pa[i]-cost, pb[j]-cost)); } } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...