이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector <double> v1(n), v2(n);
for (int i = 0; i < n; i++)
cin >> v1[i] >> v2[i];
sort(v1.rbegin(), v1.rend());
sort(v2.rbegin(), v2.rend());
for (int i = 1; i < n; i++)
v1[i] += v1[i - 1], v2[i] += v2[i - 1];
auto solve = [](vector <double>& v, vector <double>& oth) -> double {
double best = 0;
for (int i = 0; i < v.size(); i++) {
/// iau prefixul de lungime i din v
int loc = lower_bound(oth.begin(), oth.end(), v[i]) - oth.begin();
if (loc != oth.size())
best = max(best, min(v[i], oth[loc]) - i - loc - 2);
if (loc != 0)
best = max(best, min(v[i], oth[loc - 1]) - i - loc - 1);
}
return best;
};
double ans = max(solve(v1, v2), solve(v2, v1));
cout << setprecision(4) << fixed << ans << '\n';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
sure.cpp: In lambda function:
sure.cpp:26:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v.size(); i++) {
~~^~~~~~~~~~
sure.cpp:29:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (loc != oth.size())
~~~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |