# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
303032 | Kenzo_1114 | Sure Bet (CEOI17_sure) | C++17 | 1 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int n;
double a[MAXN], b[MAXN], ans = 0.0000, sa = 0.0000, sb = 0.0000;
int main ()
{
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%lf %lf", &a[i], &b[i]);
sort(a, a + n); reverse(a, a + n);
sort(b, b + n); reverse(b, b + n);
// for(int i = 0; i < n; i++) printf("a[%d] = %.4lf\n", i, a[i]);
// for(int i = 0; i < n; i++) printf("b[%d] = %.4lf\n", i, b[i]);
int ida = 0, idb = 0;
for(int i = 0; i < n; i++)
{
if(sa >= sb && idb < n) sb += b[idb++];
else if(sa < sb && ida < n) sa += a[ida++];
else break;
ans = max(ans, min(sa, sb) - i - 1);
}
printf("%.4lf\n", (double) ans);
}
/*
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
*/
컴파일 시 표준 에러 (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... |