| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 843499 | vjudge1 | Sure Bet (CEOI17_sure) | C++98 | 2045 ms | 1872 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#define COPYRIGHT CODE BY TRINH TUAN NGHIA
#include<bits/stdc++.h>
#define Boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#define ll long long
#define endl "\n"
#define st first
#define nd second
#define ii pair <ll,ll>
#define iii pair <ll,ii>
#define iiii pair <ii,ii>
#define pb push_back
#define NAME "surebet"
using namespace std;
const ll N = 1e5 + 10;
double a[N];
double b[N];
ll n;
ll na, nb;
double sa, sb;
void inp (){
cin >> n;
for (int i = 1; i <= n; ++i){
cin >> a[i] >> b[i];
}
}
void solve(){
double l = 0, r = 1e9;
sort (a + 1,a + n + 1, greater<>());
sort (b + 1, b + n + 1, greater<>());
double ans =0 ;
for (int i = 0; i <= 2 * n; ++i){
sa = 0;
na = 0;
sb = 0;
nb = 0;
l = 0;
r = 1e9;
for (int j = 0 ; j <= 60; ++j){
double m = (l + r) / 2;
while (sa - i < m and na < n){
sa += a[na + 1];
//cout << "Dcm " << sa << " " << m << endl;
++na;
}
while (sb - i < m and nb < n){
sb += b[nb + 1];
++nb;
}
while (sa - i - a[na] >= m){
sa -= a[na];
//cout << "Dcm " << sa << " " << m << endl;
--na;
}
while (sb - i - b[nb] >=m){
sb -= b[nb];
//cout << "cmm " << sb << " " << m << endl;
--nb;
}
//cout << na << " " << nb << " " << i << endl;
//cout << sa << " " << sb << endl ;
if (na + nb <= i and sa - i >= m and sb - i >= m){
l = m;
ans = max(ans, m);
//cout << setprecision(4)<< fixed<< m << endl;
}
else r = m;
//if (i == 3) cout << setprecision(4) << fixed << sa << " " << sb << endl;
}
}
cout << setprecision(4) << fixed << ans;
}
signed main (){
if (fopen(NAME".inp", "r")){
freopen(NAME".inp", "r", stdin);
freopen(NAME".out", "w", stdout);
}
Boost;
inp();
solve();
}
/*
input
*/
/*
output
*/
컴파일 시 표준 에러 (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... | ||||
