# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
854639 | anhphant | Sure Bet (CEOI17_sure) | C++14 | 2036 ms | 4948 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ldb;
#define endl '\n'
ll N;
ldb A[100007], B[100007];
void initialize() {
ios_base :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen("FILE.INP", "r")) {
freopen("FILE.INP", "r", stdin);
freopen("FILE.OUT", "w", stdout);
}
cin >> N;
for(int i = 1; i <= N; ++i) cin >> A[i] >> B[i];
sort(A + 1, A + 1 + N, greater<ldb>());
sort(B + 1, B + 1 + N, greater<ldb>());
/*for(int i = 1; i <= N; ++i) {
cerr << A[i] << " " << B[i] << endl;
}*/
}
namespace subtask2 {
void solve() {
ldb sum1 = 0;
ldb ans = 0;
for(int i = 0; i <= N; ++i) {
sum1 += A[i];
ldb sum2 = 0;
for(int j = 0; j <= N; ++j) {
sum2 += B[j];
ans = max(ans, min(sum1 - ldb(i + j), sum2 - ldb(i + j)));
//cerr << i << " " << j << " " << i + j << endl;
//cerr << setprecision(4) << sum1 << " " << sum2 << " " <<
//sum1 - ldb(i + j) << " " << sum2 - ldb(i + j) << endl;
}
}
cout << fixed << setprecision(4) << ans;
}
void process() {
solve();
}
}
int main() {
initialize();
subtask2 :: process();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |