This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define pb push_back
const ll N = 1000 + 10;
const ll LOG = 20;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 10;
int n;
long double a[N], b[N], ans = -INF, psa[N], psb[N];
int main() {
cin >> n;
for (int i = 1; i <= n; i++){
cin >> a[i] >> b[i];
}
sort(a + 1, a + n + 1); sort(b + 1, b + n + 1);
reverse(a + 1, a + n + 1); reverse(b + 1, b + n + 1);
for (int i = 1; i <= n; i++){
psa[i] = psa[i - 1] + a[i];
psb[i] = psb[i - 1] + b[i];
}
for (int i = 1; i <= n; i++){
for (int j = 1; j <= n; j++){
ans = max(ans, min(psa[i], psb[j]) - (long double)i - (long double)j);
}
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |