# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
311258 | bigg | Sure Bet (CEOI17_sure) | C++14 | 78 ms | 3580 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef double ll;
const int MAXN = 1e5 + 10;
ll prefa[MAXN], prefb[MAXN], a[MAXN], b[MAXN];
int n;
double cura = 0, curb = 0;
int main(){
scanf("%d", &n );
for(int i = 0; i < n; i++){
scanf("%lf %lf", &a[i], &b[i]);
}
sort(a , a + n);
sort(b , b + n);
reverse(a, a + n);
reverse(b, b + n);
double ans = 0;
int it1 = 0, it2 = 0;
for(int i = 0; i < 2*n; i++){
if(cura >= curb && it2 < n) curb += b[it2], it2++;
else if(cura < curb && it1 < n) cura += a[it1], it1++;
ans = max(ans, min(cura, curb) - i - 1);
}
printf("%.4lf\n", ans);
}
컴파일 시 표준 에러 (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... |