# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
152616 | Mercenary | Sure Bet (CEOI17_sure) | C++14 | 2 ms | 380 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#define pb push_back
#define mp make_pair
#define taskname "A"
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int maxn = 1e5 + 5;
int n;
ld a[maxn] , b[maxn];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if(fopen(taskname".INP","r")){
freopen(taskname".INP", "r",stdin);
freopen(taskname".OUT", "w",stdout);
}
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);
int j = n;
ld suml = 0 , sumr = 0;
ld res = 0;
for(int i = n ; i >= 0 ; --i){
res = max(res , min(suml, sumr) - 2 * n + i + j);
while(j >= 1 && suml >= sumr){
sumr += b[j--];
res = max(res , min(suml, sumr) - 2 * n + i + j - 1);
}
suml += a[i];
res = max(res , min(suml, sumr) - 2 * n + i + j - 2);
}
cout << fixed << setprecision(4) << res;
}
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... |