이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///* __ __ __ */
///* ====== _ /| /| __ _ / | | /| | @ | | | | / /| |\ | / | | @ | / */
///* \- || |_| |_ / |/ | | | |_ |- | |--| /-| | | \ \ |==| |- /=| | \ | | |--| | |- */
///* || | | |_ / | |__| _| |_ \__ | | / | |__ | __| | | | \ / | | \| \__ | | | | \ */
///*
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define int long long
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef vector<pii> vii;
const int N = 3e5+50, inf = 1e18, mod = 1e9+7;
void solve(){
int n;
cin >> n;
vd a(n+1), b(n+1);
for(int i = 1; i <= n; i++)cin >> a[i] >> b[i];
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
int ok = 1, i = 0, j = 0;
double ans = 0, smj = 0, smi = 0, cnt = 0;
while(ok){
ok = 0;
if(smj <= smi && ans <= max(smj+b[j]-(cnt+1) , smi-(cnt+1) )){
smj += b[j++];
ok = 1;
cnt++;
}
else if(smi <= smj && ans <= max(smj-(cnt+1) , smi+a[i]-(cnt+1) )){
smi += a[i++];
ok = 1;
cnt++;
}
ans = max(ans, min(smj-cnt, smi-cnt));
}
cout << fixed << setprecision(4);
cout << ans << '\n';
}
main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int test = 1;
//cin >> test;
while(test--){
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
sure.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
46 | main(){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |