이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100005;
double odds [2][N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> odds[0][i] >> odds[1][i];
}
sort(odds[0], odds[0] + n, greater<double>());
sort(odds[1], odds[1] + n, greater<double>());
double res = 0;
double val1 = 0;
int j = -1;
for (int i = 0; i < n; i++) {
double val2 = 0;
val1 += odds[0][i];
int goal = -1;
for (int j = 0; j < n; j++) {
val2 += odds[1][j];
if (val2 >= val1) {
goal = j;
break;
}
}
res = max(res, min(val1, val2) - i - goal - 2);
if (goal != 0) {
val2 -= odds[1][goal];
goal--;
}
res = max(res, min(val1, val2) - i - goal - 2);
}
cout << fixed << setprecision(4) << res << "\n";
}
/*
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
*/
컴파일 시 표준 에러 (stderr) 메시지
sure.cpp: In function 'int main()':
sure.cpp:25:9: warning: unused variable 'j' [-Wunused-variable]
25 | int j = -1;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |