답안 #1088503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1088503 2024-09-14T14:16:23 Z 4QT0R Sure Bet (CEOI17_sure) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

vector<double> a;
vector<double> b;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i<n; i++)cin >> a[i] >> b[i];
	sort(a.begin(),a.end(),greater<double>());
	sort(b.begin(),b.end(),greater<double>());
	int ind=0;
	double ans=0,sma=0,smb=0;
	for (int i = 0; i<n; i++){
		sma+=a[i];
		while(ind<n && sma>smb+b[ind])smb+=b[ind++];
		ans=max(ans,min(sma,smb)-(double)(i+1+ind));
		if (ind<n)smb+=b[ind++];
		ans=max(ans,min(sma,smb)-(double)(i+1+ind));
	}
	cout << fixed << setprecision(4) << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -